Re: strtotime time zone trouble

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Marcus Bointon wrote:

How is this not a bug?

<?php
print date('Y-m-d H:i:s', strtotime('now UTC'))."\n";
print date('Y-m-d H:i:s', strtotime('now PST'))."\n";
?>

outputs:
2005-01-18 09:58:09 (correct)
2005-01-18 17:58:09 (incorrect)

PST = UTC - 8, therefore if you ask for strtotime in PST it will give you now + 8. This is standard in most languages, you are just reading the functionality back to front.
ie when you say strtotome('now PST'), what you are asking for is the current local time (UTC in your instance) given an input date in PST



The time zone correction is applied in the wrong direction. Does it in both current PHP 4 and 5.


Named time zones like these are supposedly deprecated, but the suggested alternative in the docs doesn't work at all:

print date('Y-m-d H:i:s', strtotime('now UTC-0800'))."\n";

try print date('Y-m-d H:i:s', strtotime('now') -0800)."\n";

Tom

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux