You are here: How-to: time-zone conversion by name? « All PHP « IT news, forums, messages
How-to: time-zone conversion by name?

Posted by Shai Halevi on 08/09/06 02:33

I'm trying to write a general-purpose PHP code for the following task:

Step 1: The user specifies some date in the future (call it "the
deadline"), which I parse via strtotime. This date is stored in the
database.

Step 2: Every time the user returns to the site, it sees a message
saying, "deadline is XXX, time now is YYY". (Or maybe "deadline is XXX,
time left is YYY").

So far no problem. But I also want the user to specify in Step 1 in
what time-zone these XXX and YYY should be displayed. For example, the
user can ask to specify the dates in America/New_York time, or in UTC,
or in the server's local time, or whatever.

Moreover, this is to be a "general-purpose code", I don't know the
local time-zone of the server, nor can I make any assumptions ahead of
time about whether or not daylight saving time it observed in either
the server's time-zone or the target time-zone. (And if it is observed
in both, I don't know if the switch occurs at the same time in both.)
Finally, this should work with PHP 4.x (so no date_default_timezone_set
for me), and I cannot rely on the timezone environment variable being
available either.

One possible way to solve this is to compute the offset between the
target time and the server time (or between the target time and UTC) at
the deadline. Can anyone explain to me how to do that under the
constraints from above?

Thanks,

-- Shai Halevi

 

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

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