I have been having issues with a script that counts-down a timer. It has been found that it is apparently due to the systems UNIX Timestamp being off by one hour. (I am in America - New York, Eastern Standard or UTC -5)
I have confirmed that in virtualmin the correct timezone to be set. (America New_York Eastern Time ) On the System info page it is displaying the correct time / date. BUT I added the below line to my footer page in a site on the server and it gives me a timestamp of an hour earlier...
<!-- SERVER's UNIX TIMESTAMP: <?php echo time(); ?> -->
For example: At 3:35 (my real time) I checked this and got the UNIX timestamp of: 1329510902
Using: http://www.unixtimestamp.com/index.php This is the result: (1 hour off..) TIME STAMP: 1329510902 DATE (M/D/Y @ h:m:s): 02 / 17 / 12 @ 2:35:02pm EST
Any thoughts on where this issue could be and how to fix it? It is causing havoc on my sites.. Thanks a lot!
Submitted by JamieCameron on Fri, 02/17/2012 - 14:58 Comment #1
If you display the Unix time from the shell with a command like :
perl -e 'print time(),"\n"'
does it match what your PHP script shows?
Submitted by kappler0 on Fri, 02/17/2012 - 17:18 Pro Licensee Comment #2
Yes it does show the same result running that command. 1 hour off..
Submitted by JamieCameron on Fri, 02/17/2012 - 18:16 Comment #3
I guess your system's time is out of sync then.
The quick fix is to run :
If that command is missing, run
yum install ntpdateto install it.
Submitted by kappler0 on Fri, 02/17/2012 - 18:45 Pro Licensee Comment #4
I am getting this:
[root@host01 ~]# ntpdate pool.ntp.org 17 Feb 19:35:58 ntpdate: the NTP socket is in use, exiting [root@host01 ~]#
I installed this before (i believe) through vmin via yum. It is set to the correct timezone... screenshots below..
Did i set it up wrong maybe? Thanks!
Submitted by JamieCameron on Fri, 02/17/2012 - 19:01 Comment #5
That error means that your system is running
ntpdin the background, which should be syncing time for you already.
Try running :
Submitted by kappler0 on Fri, 02/17/2012 - 20:04 Pro Licensee Comment #6
Wow, this is really strange.. After running the below i get the same results
[root@host01 ~]# /etc/init.d/ntpd stop
Shutting down ntpd: [ OK ]
[root@host01 ~]# ntpdate pool.ntp.org
17 Feb 20:33:50 ntpdate: adjust time server 126.96.36.199 offset -0.009433 sec
[root@host01 ~]# /etc/init.d/ntpd start
Starting ntpd: [ OK ]
It didn't change anything.. Are there settings hidden somewhere that is making it think i am not on Eastern time maybe? I did check the php.ini through vmin and it is set to tthe same EST...
What is strange is that if i run date it gives me the right time but the timestamp still shows the hour offset..
[root@host01 etc]# date Fri Feb 17 21:00:06 EST 2012 [root@host01 etc]#
This is the output i get on my source page.. (a few seconds later)
Translation: TIME STAMP: 1329530432 DATE (M/D/Y @ h:m:s): 02 / 17 / 12 @ 8:00:32pm EST
Submitted by JamieCameron on Fri, 02/17/2012 - 23:58 Comment #7
So it looks like your system's time is correct, but PHP is not doing timezone conversions properly.
What line do you have in php.ini to set the timezone exactly? Generally that isn't needed, as PHP will pick up the system's timezone.
Submitted by kappler0 on Sat, 02/18/2012 - 09:15 Pro Licensee Comment #8
In my php.ini file the following is there:
I used vmin to select the zone - never did any manual edits if that matters..
; Defines the default timezone used by the date functions
; date.timezone = America/New_York
;date.default_latitude = 31.7667
;date.default_longitude = 35.2333
;date.sunrise_zenith = 90.583333
;date.sunset_zenith = 90.583333
Submitted by JamieCameron on Sat, 02/18/2012 - 12:02 Comment #9
Looks like those are commented out .. is
date.timezoneis set anywhere and not commented out?
If so, I'd recommend removing it, and restart Apache.
Submitted by kappler0 on Sat, 02/18/2012 - 14:53 Pro Licensee Comment #10
Do you know where I would be able to find if there is or a way to search for it? I haven't intentionally set anything or changed any files with this so I really just don't know if / how it would exist...
Thanks a lot.
Submitted by kappler0 on Sat, 02/18/2012 - 15:42 Pro Licensee Comment #11
I only have two domains on this box so i went in and edited the following files: (commented out all the date.timezone lines)
/etc/php.ini /home/domain1/etc/php.ini /home/domain1/etc/php5/php.ini
Then restarted apache, and i am still getting the same thing... 1hour off... from php...
I don't get it? Any other ideas? I am at a complete loss now..
Submitted by JamieCameron on Sat, 02/18/2012 - 20:43 Comment #12
You may have to ask PHP experts about this one .... it seems that this is a PHP issue, rather than an Apache or Virtualmin bug.