Finding out DST with PHP

Finding out DST with PHP

am 03.10.2009 03:53:55 von Rohit Sodhia

I was hoping someone might be able to help me with something. In a recent
effort to learn PHP/mySQL, I decided to design a mock forum. Many forums
(such as phpBB) allow a user to pick their timezone and to select if DST
should be applied. I'm trying to figure out how its done. Currently, I'm
saving all times as GMT, having set the default timezone to 'Europe/London'.

I then found this list of timezones:
http://unicode.org/repos/cldr/trunk/docs/design/formatting/z one_log.html#windows_ids

The issue I'm having trouble with now is DST. I just learned that not all
timezones start DST on the same day, nor do they all add one hour.

According to http://www.php.net/manual/en/datetime.getoffset.php
DateTime::getOffset should give me back the DST offset, but when I have use
DateTime::setTimezone to change the timezone and get the local users time,
it automatically applies DST if applicable, and setTimezone gives me
back -14400 (I'm testing with EST). This is -4 hours, which is the offset
from GMT to EST right now. Unless I'm using the funciton wrong, it seems to
give the offset from GMT. Can anyone lend me a thought?



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php