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

Home Posts Topics Members FAQ

Milliseconds From 1970!

I have a value that represents the time in milliseconds passed since
1970 00:00:00 GMT that I need to convert into a readable date e.g.

1092364211773 = 13/08/2004 03:30:00 GMT

Is this easily done or do I need to write my own function for this???
If that's the case, does anyone have some code to do this???

Thanks in advance

Steve
Jul 21 '05 #1
6 2062
Steve,
Have you tried the DateTime.AddMilliseconds method?

Something like:

Dim base As New DateTime(1970, 1, 1)
Dim readableDate As DateTime = base.AddMilliseconds(1092364211773)
Debug.WriteLine(readableDate, "Readable date")

Hope this helps
Jay

"Steve" <go****@valleyboy.net> wrote in message
news:7a**************************@posting.google.c om...
I have a value that represents the time in milliseconds passed since
1970 00:00:00 GMT that I need to convert into a readable date e.g.

1092364211773 = 13/08/2004 03:30:00 GMT

Is this easily done or do I need to write my own function for this???
If that's the case, does anyone have some code to do this???

Thanks in advance

Steve

Jul 21 '05 #2
Steve <go****@valleyboy.net> wrote:
I have a value that represents the time in milliseconds passed since
1970 00:00:00 GMT that I need to convert into a readable date e.g.

1092364211773 = 13/08/2004 03:30:00 GMT

Is this easily done or do I need to write my own function for this???
If that's the case, does anyone have some code to do this???


It's easy to create a DateTime for Jan 1st 1970, and a TimeSpan for
however many milliseconds you've got - then just add one to the other.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #3
This is perfect, thank you so much...

Steve
-----Original Message-----
Steve,
Have you tried the DateTime.AddMilliseconds method?

Something like:

Dim base As New DateTime(1970, 1, 1)
Dim readableDate As DateTime = base.AddMilliseconds(1092364211773) Debug.WriteLine(readableDate, "Readable date")

Hope this helps
Jay

"Steve" <go****@valleyboy.net> wrote in message
news:7a**************************@posting.google. com...
I have a value that represents the time in milliseconds passed since 1970 00:00:00 GMT that I need to convert into a readable date e.g.
1092364211773 = 13/08/2004 03:30:00 GMT

Is this easily done or do I need to write my own function for this??? If that's the case, does anyone have some code to do this???
Thanks in advance

Steve

.

Jul 21 '05 #4
Steve,
If you go the TimeSpan route as Jon suggests. You can use
TimeSpan.FromMilliseconds to get a TimeSpan with milliseconds in it.

Dim base As New DateTime(1970, 1, 1)
Dim ts As TimeSpan = TimeSpan.FromMilliseconds(1092364211773)
Dim readableDate As DateTime = base.Add(ts)

Debug.WriteLine(readableDate, "Readable date")

I'm mentioning this as I "always" forget about the TimeSpan.From* methods...
*shrug*

Hope this helps
Jay

"Steve" <go****@valleyboy.net> wrote in message
news:5c****************************@phx.gbl...
This is perfect, thank you so much...

Steve
-----Original Message-----
Steve,
Have you tried the DateTime.AddMilliseconds method?

Something like:

Dim base As New DateTime(1970, 1, 1)
Dim readableDate As DateTime =

base.AddMilliseconds(1092364211773)
Debug.WriteLine(readableDate, "Readable date")

Hope this helps
Jay

"Steve" <go****@valleyboy.net> wrote in message
news:7a**************************@posting.google. com...
I have a value that represents the time in milliseconds passed since 1970 00:00:00 GMT that I need to convert into a readable date e.g.
1092364211773 = 13/08/2004 03:30:00 GMT

Is this easily done or do I need to write my own function for this??? If that's the case, does anyone have some code to do this???
Thanks in advance

Steve

.

Jul 21 '05 #5
You can set up a DateTime Structure for the date in 1970 and then use a
TimeSpan object with the requisite number of milliseconds and add to the
first DateTime to get another DateTime.

Dim dt as DateTime = Convert.ToDateTime("1/1/1970")

'Check this next line to make sure it is in the millisecond value
Dim ts As New TimeSpan(0,0,0,0,1092364211773)

Dim dt as DateTime = dt + ts

Something like that. Check the documentation if this blows chunks, but the
theory is sound.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Steve" <go****@valleyboy.net> wrote in message
news:7a**************************@posting.google.c om...
I have a value that represents the time in milliseconds passed since
1970 00:00:00 GMT that I need to convert into a readable date e.g.

1092364211773 = 13/08/2004 03:30:00 GMT

Is this easily done or do I need to write my own function for this???
If that's the case, does anyone have some code to do this???

Thanks in advance

Steve

Jul 21 '05 #6
George,

In my opinion it is better to use as Jay showed
Dim base As New DateTime(1970, 1, 1)

That is independent from the culture settings.
(Assuming the time Steve is from the US however when others read this).

Cor
Jul 21 '05 #7

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

Similar topics

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.
6
by: Steve | last post by:
I have a value that represents the time in milliseconds passed since 1970 00:00:00 GMT that I need to convert into a readable date e.g. 1092364211773 = 13/08/2004 03:30:00 GMT Is this easily...
6
by: Steve | last post by:
I have a value that represents the time in milliseconds passed since 1970 00:00:00 GMT that I need to convert into a readable date e.g. 1092364211773 = 13/08/2004 03:30:00 GMT Is this easily...
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...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.