473,466 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

May 21 '07 #1
3 12243
vu******@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

May 21 '07 #2
On May 21, 12:19 pm, Torsten Robitzki <MyFirstn...@Robitzki.dewrote:
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

May 21 '07 #3
In comp.lang.javascript message <11**********************@r3g2000prh.goo
glegroups.com>, Mon, 21 May 2007 09:02:37, vu******@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.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
May 21 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Num | last post by:
Hi all, I have to convert a J2EE date as a long ("Millis") in a .NET date as a long ("Ticks") In Java, currentTimeMillis, is the difference, measured in milliseconds, between the current time...
4
by: David | last post by:
We only know the system ticks count, but we have no date or time function. So we need the source code about solving the problem. I have googled several times and no good results. can u help me? ...
9
by: HL | last post by:
I am using VS 2005 Beta - C# Problem: The Timer fires a few milliseconds before the actual Due-Time Let's say a timer is created in the following manner: System.Threading.Timer m_timer = null;...
10
by: yaron | last post by:
Hi, I do i get the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC. like in java System.currentTimeMillis() ? Thanks.
2
by: Harlin Seritt | last post by:
How can I take a time given in milliseconds (I am doing this for an uptime script) and convert it to human-friendly time i.e. "4 days, 2 hours, 25 minutes, 10 seonds."? Is there a function from the...
1
by: Benny Schudel | last post by:
hello I've tried to convert some milliseconds to a time format. $ms = 100000 // 1min 40sec echo strftime('%H:%M:%S', $ms/1000); i expect the result is: "00:01:40" but the result ist:...
2
by: Takeadoe | last post by:
Gang - Is it possible to change a string such as "11/28/2006 11:30 AM" to a valid date/time format in Accces? Mike
2
by: vinodtr | last post by:
Hi all, I have a date which is represented by the number of milliseconds since January 01, 1970. I need to change this back to DATE format. Is there any built in function in DB2 to do the needed...
4
by: aext | last post by:
Hi I tried to read time value from file and I found that this value is decimal one and not a time stamp this value (29940722) was shown . How can I convert it to a real date/time value. ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.