Re: strtotime time zone trouble
| From: | Tom | Date: | Tue, 18 Jan 2005 10:53:30 +0000 |
| Subject: | Re: strtotime time zone trouble | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-206627@lists.php.net to get a copy of this message | ||
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