Jump to content

Php Date() Shows Incorrect Server Time


Recommended Posts

Hi TCH'ers,


I have submitted this issue through the help desk but I am hoping I can get some assistance here.


We've encountered a strange bug of some sort with the date() function in PHP.


Here's what's happening: upon calling date(), we are getting times that seem to fluctuate by 2 hours in either direction.


You can hit this file to test: http://uwarboretum.org/phpinfo.php


Reload it many many times and watch the time change back and forth from 4am to 6am.


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!!




echo "<p>The current time: " . date("g:i:sa") . "</p>";

echo "<p>This is date(\"g:ia\", 39600): [[" . date("g:ia",39600) . "]]</p>";




This is causing all sorts of havoc on our site -- as you can imagine when event dates and times start changing at random.


We have already logged this on PHP.net but haven't received any helpful feedback there.


I'd really appreciate any insight you folks can provide. Thanks very much!

Link to comment
Share on other sites

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.


You could easily set up a loop that echos the php date and see if it changes during the loop.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...