Convert milliseconds after midnight January 1, 1970 GMT to formatted time

V

vunet.us

What is the best method to convert milliseconds (after midnight
January 1, 1970 GMT) to formatted time

example:
972798180000 ==> 10/18/2000 14:08:11
 
T

Torsten Robitzki

What is the best method to convert milliseconds (after midnight
January 1, 1970 GMT) to formatted time

example:
972798180000 ==> 10/18/2000 14:08:11
new Date(972798180000).toLocaleString()

or in case you need that specific format: use the varius
getMonth/getDate/getFullYear, etc. and compose the needed string out of
this values.

reagards,
Torsten
 
V

vunet.us

new Date(972798180000).toLocaleString()

or in case you need that specific format: use the varius
getMonth/getDate/getFullYear, etc. and compose the needed string out of
this values.

reagards,
Torsten

thanks
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]
glegroups.com>, Mon, 21 May 2007 09:02:37, (e-mail address removed) posted:
What is the best method to convert milliseconds (after midnight
January 1, 1970 GMT) to formatted time

Conventionally, midnight is the end of the day. You mean 1970-01-01
00:00:00 GMT.
example:
972798180000 ==> 10/18/2000 14:08:11

That's not a sensible format for the Internet. The average American
will want 12-hour clock time, and the rest of the world won't want FFF
date field order. Convert it to YYYY-MM-DD hh:mm:ss, which is
comprehensible and unambiguous everywhere.

From that number, I get 20000-10-29 05:43:00. Your value is clearly
wrong, as an even multiple of 10 seconds from 1970.0 should give an even
multiple of 10 seconds in hh:mm:ss notation.

Then, of course, you must add UTC, GMT, or Z; or convert to local civil
time. The latter is only easy if there was no significant change in the
local Summer Time rules between the date/time in question and the
present moment, except possibly with a combination of Vista and a non-
compliant Javascript implementation.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top