Date and timezone issue
| From: | Charlie van de Kerkhof | Date: | Mon, 08 May 2006 17:11:25 +0000 |
| Subject: | Date and timezone issue | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-24001@lists.php.net to get a copy of this message | ||
Hi,
I'm trying to get and transform dates into my own timezone.
The server is in Miami(?) time-zone id 'EDT' or 'EST'.
I'm in the netherlands, time-zone 'CET'.
When I get a new date:
$oNow = new Date();
output:
date Object
(
[year] => 2006
[month] => 05
[day] => 08
[hour] => 12
[minute] => 46
[second] => 27
[partsecond] => 0
[tz] => date_timezone Object
(
[id] => UTC
[longname] => Coordinated Universal Time
[shortname] => UTC
[hasdst] =>
[dstlongname] => Coordinated Universal Time
[dstshortname] => UTC
[offset] => 0
[default] =>
)
[getWeekdayAbbrnameLength] => 3) Which is basically not true (time-zone) but I know that if the 'guess' is not good then it will be UTC. I set the timezone, because I know where the server is: $oNow->setTZ('EST'); // EDT is not known in the $GLOBALS['_DATE_TIMEZONE_DATA'] array then it ouputs: date Object (
[year] => 2006
[month] => 05
[day] => 08
[hour] => 13
[minute] => 04
[second] => 50
[partsecond] => 0
[tz] => date_timezone Object
(
[id] => EST
[longname] => Eastern Standard Time
[shortname] => EST
[hasdst] => 1
[dstlongname] => Eastern Daylight Time
[dstshortname] => EDT
[offset] => -18000000
[default] =>
)
[getWeekdayAbbrnameLength] => 3) So I guess this is ok. Now I want to change the date to the users time-zone. Based on the IP I get the TZ id like 'Europe/Amsterdam'. When I convert the current date to this timezone: $oNow->convertTZbyID('Europe/Amsterdam'); Output: date Object (
[year] => 2006
[month] => 5
[day] => 8
[hour] => 20
[minute] => 4
[second] => 50
[partsecond] => 0
[tz] => date_timezone Object
(
[id] => Europe/Amsterdam
[longname] => Central European Time
[shortname] => CET
[hasdst] => 1
[dstlongname] => Central European Summer Time
[dstshortname] => CEST
[offset] => 3600000
[default] =>
)
[getWeekdayAbbrnameLength] => 3) And that is one hour to many! ;) Do anyone of you know I'm doing the right thing (or has a better idea) or is it something that is hard to do because of the daylight saving time issue? Thanx in advance! - Charlie