peregrine Posted February 27, 2007 Share Posted February 27, 2007 Hi folks, searched for an answer (both here and on the web at large) and came up with nothing. Running PHP 5.1.6 on Fedora Core 6. PHP's reported timezone does not match up with the system's. Western Australia had a trial of daylight savings time abruptly introduced from December 2006 to March 2007 (and again for the following two summers). Fedora has updated to correctly handle this change, but it seems PHP has not. Example: php > echo date("e",time()); Australia/Perth php > echo date("r",time()); Tue, 27 Feb 2007 09:44:27 +0800 ... bash-3.1$ date -R Tue, 27 Feb 2007 10:44:44 +0900 (+0800 is standard time, +0900 is daylight savings time. Switching the system date until after DST ends makes these two match up again, at +0800.) Everything I've found suggests that PHP just reads a system timezone file somewhere, but it's clearly not the same one Fedora is using. (/etc/localtime and /usr/share/zoneinfo/Australia/Perth are correct and up to date.) How can I make PHP keep up with this timezone change? Quote Link to comment Share on other sites More sharing options...
corbin Posted February 27, 2007 Share Posted February 27, 2007 It would be sloppy, but you could add an if clause every time you use time or date and make it change it automatically depending on the time of the year and what not. Quote Link to comment Share on other sites More sharing options...
peregrine Posted February 28, 2007 Author Share Posted February 28, 2007 It would be sloppy, but you could add an if clause... Yes I could, and yes it would. I'd rather leave it as-is and show "+0800"; having it in local time is just a convenience for users in the particular case I'm working on. But I'd much rather find out how to make PHP use up-to-date timezone data automagically. Can anyone help? (When I said that I'd found claims that PHP reads a system file, what I'd been looking at was a lot of discussion about North American timezone changes. So I'm sure there must be someone who's experienced this same problem, in another time and on another continent...) Quote Link to comment Share on other sites More sharing options...
btherl Posted February 28, 2007 Share Posted February 28, 2007 You could use strace to see what files php opens. Here on my debian system it opens /etc/localtime, which links to /usr/share/zoneinfo/Australia/Melbourne (actually I am in singapore but my system runs on Melbourne time) Quote Link to comment Share on other sites More sharing options...
peregrine Posted March 6, 2007 Author Share Posted March 6, 2007 You could use strace to see what files php opens. Thank you, this was very helpful. Among the output, I find this: open("/etc/localtime", O_RDONLY) = 3 So it does appear to be reading from /etc/localtime (which oddly is not a link to anything). But /etc/localtime does have the up-to-date daylight savings information: bash-3.1$ zdump -v /etc/localtime | grep "2006\|2007" /etc/localtime Sat Dec 2 17:59:59 2006 UTC = Sun Dec 3 01:59:59 2006 WST isdst=0 gmtoff=28800 /etc/localtime Sat Dec 2 18:00:00 2006 UTC = Sun Dec 3 03:00:00 2006 WST isdst=1 gmtoff=32400 /etc/localtime Sat Mar 24 17:59:59 2007 UTC = Sun Mar 25 02:59:59 2007 WST isdst=1 gmtoff=32400 /etc/localtime Sat Mar 24 18:00:00 2007 UTC = Sun Mar 25 02:00:00 2007 WST isdst=0 gmtoff=28800 /etc/localtime Sat Oct 27 17:59:59 2007 UTC = Sun Oct 28 01:59:59 2007 WST isdst=0 gmtoff=28800 /etc/localtime Sat Oct 27 18:00:00 2007 UTC = Sun Oct 28 03:00:00 2007 WST isdst=1 gmtoff=32400 I am utterly confused now. Help? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.