472,102 Members | 2,027 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,102 software developers and data experts.

Convert UTC to Local Time

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

Mar 8 '07 #1
6 21026
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
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
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
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
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
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.

Similar topics

5 posts views Thread by ECVerify.com | last post: by
1 post views Thread by XML newbie: Urgent pls help! | last post: by
1 post views Thread by davelist | last post: by
2 posts views Thread by ZR | last post: by
8 posts views Thread by deepak_kamath_n | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.