Reply to Re: Working with Timezones and DST

Your name:

Reply:


Posted by Daz on 05/27/07 14:15

On May 27, 2:58 pm, Andy Hassall <a...@andyh.co.uk> wrote:
> On 27 May 2007 06:24:49 -0700, Daz <cutenfu...@gmail.com> wrote:
>
>
>
> >I am creating a JavaScript project which will allow users to see what
> >time it is in other countries. I am wondering if there's any way to
> >have the server work this out, without having to update a database
> >constantly with the times and dates that certain countries set their
> >clocks back or forward.
>
> >Can this be done, or do I need to connect to a time server? Ideally, I
> >need a time server that will return a JavaScript object containing the
> >information I need, but I don't think one exists.
>
> >Please could someone suggest the steps I need to take to quickly
> >obtain the correct time for any given country, which will take DST
> >into account? Sadly, to my knowledge, the UK is the only country that
> >has hard-coded rules for when the clocks are changed, where as it
> >seems to be a political thing for all other countries.
>
> >If I have to run a database with this information, then so be it, but
> >it seems like a lot of manual work, and I'm not sure how often I'd
> >need to update it.
>
> Most operating systems have comprehensive timezone data available, which gets
> taken into account via the TZ environment variable when formatting UNIX
> timestamps (which are always based on UTC).
>
> PHP 5.1 introduced improved timezone handling into the core of PHP itself,
> see:http://uk2.php.net/manual/en/function.date-default-timezone-set.php(which
> is preferred over setting environment variables, if available).
>
> <?php
> foreach (array('US/Eastern', 'US/Central', 'UTC', 'Europe/London',
> 'Europe/Paris') as $tz)
> {
> putenv("TZ=$tz"); // or use date_default_timezone_set
> print date("r") . " (TZ=$tz)\n";}
>
> ?>
>
> $ php test.php
> Sun, 27 May 2007 09:56:21 -0400 (TZ=US/Eastern)
> Sun, 27 May 2007 08:56:21 -0500 (TZ=US/Central)
> Sun, 27 May 2007 14:56:21 +0100 (TZ=Europe/London)
> Sun, 27 May 2007 15:56:21 +0200 (TZ=Europe/Paris)
> Sun, 27 May 2007 13:56:21 +0000 (TZ=UTC)
>
> --
> Andy Hassall :: a...@andyh.co.uk ::http://www.andyh.co.ukhttp://www.andyhsoftware.co.uk/space:: disk and FTP usage analysis tool

Hi Andy. That's wonderful. Thank you very much for such a great
example. Sadly, the server I am doing this project for, is running PHP
4...

Am I correct in saying that DST has been accounted for in your
example? It looks like it has, but I need to be certain.

Thanks again.

Daz.

[Back to original 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

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