You are here: Re: [PHP] strtotime time zone trouble « PHP « IT news, forums, messages
Re: [PHP] strtotime time zone trouble

Posted by Tom on 01/18/05 12:53

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация