By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,666 Members | 1,909 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,666 IT Pros & Developers. It's quick & easy.

Convert UTC to Local Time

P: n/a
How can I convert UTC time such as 1173451235415 to a local time I can
read? Thank you

Mar 8 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Mar 8, 1:46 pm, vunet...@gmail.com wrote:
How can I convert UTC time such as 1173451235415 to a local time I can
read? Thank you
gmtDate=new Date(UTC Date)

e.g.-
alert(Date(1173451235415))

Mar 8 '07 #2

P: n/a
On Mar 8, 3:01 pm, scripts.cont...@gmail.com wrote:
On Mar 8, 1:46 pm, vunet...@gmail.com wrote:
How can I convert UTC time such as 1173451235415 to a local time I can
read? Thank you

gmtDate=new Date(UTC Date)

e.g.-
alert(Date(1173451235415))
thank you, my problem was that 1173451235415 could not be a string.
when i parseInt(sometime), it works well. thank you very much.

Mar 8 '07 #3

P: n/a
On Mar 8, 3:05 pm, vunet...@gmail.com wrote:
How can I convert UTC time such as 1173451235415 to a local time I can
read? Thank you
gmtDate=new Date(UTC Date)
thank you, my problem was that 1173451235415 could not be a string.
even a string should work-
Date("1173451235415")
when i parseInt(sometime), it works well. thank you very much.
or +sometime
e.g
Date(+somtime)
Mar 8 '07 #4

P: n/a
On Mar 8, 4:53 pm, scripts.cont...@gmail.com wrote:
On Mar 8, 3:05 pm, vunet...@gmail.com wrote:
How can I convert UTC time such as 1173451235415 to a local time I can
read? Thank you
gmtDate=new Date(UTC Date)
thank you, my problem was that 1173451235415 could not be a string.

even a string should work-
Date("1173451235415")
when i parseInt(sometime), it works well. thank you very much.

or +sometime
e.g
Date(+somtime)
hm... i'll check the type. it could be XML too (after parsing).

Mar 8 '07 #5

P: n/a
In comp.lang.javascript message <11*********************@30g2000cwc.goog
legroups.com>, Thu, 8 Mar 2007 13:53:45, sc*************@gmail.com
posted:
>On Mar 8, 3:05 pm, vunet...@gmail.com wrote:
How can I convert UTC time such as 1173451235415 to a local time I can
read? Thank you
gmtDate=new Date(UTC Date)
>thank you, my problem was that 1173451235415 could not be a string.

even a string should work-
Date("1173451235415")
>when i parseInt(sometime), it works well. thank you very much.

or +sometime
e.g
Date(+somtime)
Don't post untested code; it shows that you overestimate your ability.
In IE6 at least, Date(X) ignores the value of X. See ISO 16262
sections 15.9.2 & 15.9.2.1 which seem not to agree; ECMA-262 likewise.

Calling new Date(1173451235415) does no conversion; the digits are
converted to an IEEE Double (type Number) outside the call, and that
value is copied into the newly-created Date Object.

The default conversion from Date Object to String, and some of the
explicit Methods, convert to unspecified string forms of local
date/time.

While your answer seems to have satisfied vunet's immediate need, it
will not have taught him much.

It's a good idea to read the newsgroup 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.
Mar 9 '07 #6

P: n/a
On Mar 8, 5:44 pm, Dr J R Stockton <reply0...@merlyn.demon.co.uk>
wrote:
or +sometime
e.g
Date(+somtime)

Don't post untested code; it shows that you overestimate your ability.
that wasn't untested. I tested that before replying.
In IE6 at least, Date(X) ignores the value of X. See ISO 16262
sections 15.9.2 & 15.9.2.1 which seem not to agree; ECMA-262 likewise.

you are right. It doesn't work. It just ignores the X. I tested but i
didn't notice the date it returned was today's date.

Calling new Date(1173451235415) does no conversion; the digits are
converted to an IEEE Double (type Number) outside the call, and that
value is copied into the newly-created Date Object.
but in help, it says -
new Date(dateVal)
If a numeric value, dateVal represents the number of milliseconds in
Universal Coordinated Time between the specified date and midnight
January 1, 1970.

It alerts the correct year but not the month and date.

sorry vunet, dont use these methods. They return the wrong date.

Mar 9 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.