|
|
 |
 |
 |
 |
Javascript / Client Side Development
|
 |
 |
 |
 |
 |
 |
 |
 |
Convert milliseconds after midnight January 1, 1970 GMT to formatted time
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
vunet @gmail.com wrote: > 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
On May 21, 12:19 pm, Torsten Robitzki <MyFirstn@Robitzki.de> wrote: > vunet @gmail.com wrote: > > 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
thanks
In comp.lang.javascript message <1179763357.335087.148@r3g2000prh.goo glegroups.com>, Mon, 21 May 2007 09:02:37, vunet@gmail.com 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. -- (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.htm> jscr maths, dates, sources. <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
|
 |
 |
 |
 |
|