PHP Timezone Issue

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Toasty
-


Joined: 21 Feb 2008
Posts: 298
Location: Chicago, IL

PostPosted: Fri Mar 20, 2009 11:16 pm    Post subject: PHP Timezone Issue Reply with quote

Hello,

I've been having an issue with PHP since version 5.28 (up to 5.2.9-1) with my timezone. PHP seems to be reporting the time as one hour higher than the server's system clock. This wasn't a problem when the timezone changed, but when I updated my server's time to the correct time (Win 2K Server w/Abyss X2) I noticed that posts in my forums are all one hour faster than the actual time.

I know this isn't a forum software issue, as I wrote the code and the time is shown as my local time, not adjusted:

Code:
date("l, F j, Y \\a\\t g:i:s A",$var)


I suspect it has something to do with daylight savings time...If anybody has any information on how I can adjust how PHP handles the times -- by PHP.INI preferably, please let me know!

Thanks,
Toasty
_________________
Audit the secure configuration of your server headers!
Back to top View user's profile Send private message Visit poster's website
pkSML
-


Joined: 29 May 2006
Posts: 952
Location: Michigan, USA

PostPosted: Sun Mar 22, 2009 5:41 pm    Post subject: Reply with quote

I had this same problem a while back on all my computers. It has to do DST's new rules. I just got the patch from Microsoft and all was fixed.

The download's available from this page.
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
Toasty
-


Joined: 21 Feb 2008
Posts: 298
Location: Chicago, IL

PostPosted: Mon Mar 23, 2009 1:16 pm    Post subject: Reply with quote

Thanks for the link -- only problem is that it doesn't support W2K Server... XP/Windows 2003 Server is the farthest back it goes.

I'm curious if I disable the DST in windows and manually set the time, if PHP will stop trying to be helpful and run off the system time...
_________________
Audit the secure configuration of your server headers!
Back to top View user's profile Send private message Visit poster's website
pkSML
-


Joined: 29 May 2006
Posts: 952
Location: Michigan, USA

PostPosted: Mon Mar 23, 2009 3:39 pm    Post subject: Reply with quote

Your DST settings will be incorrect
  • 3-4 weeks from the second Sunday in March until the first Sunday in April and
  • 1 week from the last Sunday in October until the first Sunday in November.


On the second Sunday in March, you could switch time zones. For example, go from -05:00 GMT to -04:00 GMT and turn off DST. Manually set timezone back and turn DST on the first Sunday in April. (You may need to change the timezone in your php.ini file as well.)

Here's a little info about DST:
Quote:
In 1986, a law was passed that shifted the starting date of daylight time to the first Sunday in April, beginning in 1987. The ending date of daylight time was not subject to such changes, and remained the last Sunday in October. The Energy Policy Act of 2005 changed both the starting and ending dates. Beginning in 2007, daylight time starts on the second Sunday in March and ends on the first Sunday in November.

Source: http://aa.usno.navy.mil/faq/docs/daylight_time.php

_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
Toasty
-


Joined: 21 Feb 2008
Posts: 298
Location: Chicago, IL

PostPosted: Tue Mar 24, 2009 10:52 am    Post subject: Reply with quote

^That's odd, I never remember experiencing anything like this in the past, and my old server was made a few years before the energy conservation act...My new server which I recently switched to is fairly new (AMD Athalon X2 2.6 GHz, and accompanying chipset), and I do have the issue...seems as if it started just this year.

I appreciate the help with that pkSML, I do find it odd that PHP is reporting a different time than my Windows clock. I figured DST would have been the issue. Thanks for the assistance!
_________________
Audit the secure configuration of your server headers!
Back to top View user's profile Send private message Visit poster's website
pkSML
-


Joined: 29 May 2006
Posts: 952
Location: Michigan, USA

PostPosted: Tue Mar 24, 2009 12:52 pm    Post subject: Reply with quote

Toasty wrote:
I do find it odd that PHP is reporting a different time than my Windows clock.


Yah, that's what happened until I applied the patch too. I had to just change the PHP timezone until I found the patch. I guess Microsoft updates *do* improve your computer sometimes!
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group