Php Date() Shows Incorrect Server Time

liunx

Guest
Hi TCH'ers,<br /><br />I have submitted this issue through the help desk but I am hoping I can get some assistance here.<br /><br />We've encountered a strange bug of some sort with the date() function in PHP. <br /><br />Here's what's happening: upon calling date(), we are getting times that seem to fluctuate by 2 hours in either direction. <br /><br />You can hit this file to test: <a href="http://uwarboretum.org/phpinfo.php" target="_blank">http://uwarboretum.org/phpinfo.php</a><br /><br />Reload it many many times and watch the time change back and forth from 4am to 6am.<br /><br />This is the PHP code from that file. As you can see, we are not doing any manipulation of the timestamp... it seems that the server time coming back is just changing on the fly!!<br /><br /><?php<br /><br />echo "<p>The current time: " . date("g:i:sa") . "</p>";<br />echo "<p>This is date(\"g:ia\", 39600): [[" . date("g:ia",39600) . "]]</p>";<br /><br />?><br /><br />This is causing all sorts of havoc on our site -- as you can imagine when event dates and times start changing at random.<br /><br />We have already logged this on PHP.net but haven't received any helpful feedback there.<br /><br />I'd really appreciate any insight you folks can provide. Thanks very much!<!--content-->
I reloaded many times and it always shows the current time for me.<!--content-->
Welcome to the forums! Loads ok for me too!<!--content-->
Refreshed it 100 times. Looks fine.<!--content-->
Welcome to the forums. I see the same time on each reload as well.<!--content-->
I have several sites that use the PHP date() function for various reasons... some of which are 'mission critical' for the site operation. I can't say I've ever seen erratic date changes. <br /><br />You could easily set up a loop that echos the php date and see if it changes during the loop.<!--content-->
Thanks everyone, for taking a look. I am still seeing the problem. Look at the attachment.<!--content-->
More evidence...<!--content-->
Here's a screenshot annotated with the current time on my PC:<br /><br /><img src="http://taylor-hughes.com/dump/datescreenshots.jpg" border="0" class="linked-image" /> <br /><br />And here's a copy of the exact same script on my server:<br /><br /><a href="http://taylor-hughes.com/dump/phpinfo.php" target="_blank">Working fine</a><!--content-->
 
Back
Top