Re: Detect Tme Zone



Trevor L. said the following on 10/13/2005 12:39 AM:
These statements display the current (local) time with UTC offset

They show the time as set on the computer, not necessarily the current local time.


var d = new Date()
document.write (d)

For me, it displayed
Thu Oct 13 14:36:20 UTC+1000 2005
(Australia is 10 hours ahead of UTC)

You could extract the offset itself by searching the string for "UTC" and taking the next 5 characters.

But it still may not be accurate, depending on the user's PC settings.

I display local time on my website by using the toLocale functions

function getTheDate()
{// returns local date
  var now = new Date()
  return now.toLocaleDateString()
}
//------------------------------

function getTheTime()
{// returns local time
  var now = new Date()
  return now.toLocaleTimeString()
}
//------------------------------
But

That doesn't show the time zone the user is in, it shows the time zone the users computer is set to. They may not always match. I live in one time zone if I travel 50 miles with my laptop, I am in a different time zone but I do not change my computer settings.


--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
.



Relevant Pages

  • Re: Network Time Protocol (NTP) client support question
    ... compensating adjustment to the time zone offset. ... The whole point of using UTC time stamps is to avoid issues ... fudging the local time offset fails to satisfy it. ...
    (bit.listserv.ibm-main)
  • Re: convert time string in UTC to time in local time
    ... I have a time stamp that looks like this (corresponding to UTC time): ... I want to convert it to my local time. ... time zone magic to treat the supplied time as a local time, ... UTC time - this seems to be an artifact of the way mktime is defined ...
    (comp.lang.python)
  • Re: Detect Tme Zone
    ... I don't want to be picky with an expert, but some (genuine) questions. ... What information is available to get local time as distinct from that set on ... > That doesn't show the time zone the user is in, ... > the users computer is set to. ...
    (microsoft.public.scripting.jscript)
  • Re: Rotor Bug: TimeZone ToLocalTime
    ... Or are you just basing this on a code examination? ... all of the information from the time zone about how to offset the times. ... into a local time fails, but not converting a utc date into a local date. ...
    (microsoft.public.dotnet.framework.clr)
  • RE: Best practice for TOD clock
    ... returns the UTC time. ... local applications that log with local time) for one hour in the fall. ... duplicate timestamps if the timestamps are using UTC time. ... For IBM-MAIN subscribe / signoff / archive access instructions, ...
    (bit.listserv.ibm-main)