In comp.lang.javascript message <14qapjqmye78s$.xh73nkck7lmw.dlg@40tude.
net>, Sat, 24 Mar 2007 09:38:53, adie <adie@oh-shit.composted:
Quote:
>the requirement is to display a time (any time) from a distinct timezone
>(lets say EST) on a webpage but to make available the conversion to the
>user local timezone based on the users system time (presume the browser
>headers contain this)
An EST date/time can be converted to UTC by a browser anywhere, provided
that the browser is also supplied with the time zone and summer time
rules for the relevant EST (Hint :- EVERY country has an Easternmost
part, and some of them have a Time Zone covering only that part of their
country), and that the rules are up-to-date (well, actually they must be
correct for the date in question), and that the time exists and is not
in the Ambiguous Autumnal Hour.
In order not to be pig-headed, you need to convert your local times to
Universal times (UTC/GMT), and to do so locally, for distribution. You
should know how your EST relates to GMT, if you live in the local EST
area. And if you do not, javascript can do it easily, on a browser
configured for your locality.
Or, better, just ignore your local time and start with UTC.
Then your transmitted data contains the UTC - since no-one really needs
to see this, send it as what +new Date() would give if run
(anywhere) on a correctly-set system at the actual time of the event.
That recently was 1174843625425 (it's milliseconds from 1970-01-01
00:00:00 Z, of course).
Then in the Web page, use new Date(ThatNumber) and output it; either
naively, to get an uncertain but locally-acceptable format for
correctly-localised browsers, or by specific code to get local time in a
globally-unambiguous format.
That means in ISO 8601, of course. Mark it as LCT, since you do not
know, and cannot determine, any other abbreviation.
Quote:
>Guess im after a small function that takes a time and converts it to
>another time based on the users browser system time
>
>For example: the schedule of the Olympic Games may be displayed as this in
>the USA (EST)
>
>22 jan 10pm ET Javelin
>22 jan 11pm ET Long Jump
>23 jan 3am ET Shooting
ET is Ephemeris Time - only astronomers will want that.
Quote:
>but in the UK (GMT) would have to be (note date also changes):
>
>23 jan 2am GMT Javelin
>23 jan 3am GMT Long Jump
>23 jan 7am GMT Shooting
Many in the UK will not like that format - many round here would like
month names in Hangul, for example. Use ISO 8601.
For the 2008 Games, the times will be originated in China Time, GMT+8,
but may be delivered in UTC.
It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.