469,900 Members | 1,716 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,900 developers. It's quick & easy.

EPOCH Time

Can someone suggest me how do i write a code in VB for
epoch time. I want if the value is entered it changes into
time and if time is enetred i get the value
Nov 20 '05 #1
2 5636
Hello,

"Sunil" <su***@intouchworld.com> schrieb:
Can someone suggest me how do i write a code in VB for
epoch time. I want if the value is entered it changes into
time and if time is enetred i get the value


Can you explain what EPOCH time is?

Regards,
Herfried K. Wagner
--
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #2
Hi Sunil,

In VB.NET dates and times are stored in a DateTime structure. The epoch
for these is 00:00:00.0000000, January 1, 0001.

DateTimes have a Ticks value which is the number of 100-nanosecond
intervals which have elapsed since then.

You can convert to and from by getting the Ticks value, and by adding
Ticks to an existing DateTime.

Try the following:

Dim dt0 As DateTime = #12/25/2003#
Dim dt1 As DateTime = DateTime.MinValue
Dim dt2 As DateTime = DateTime.MinValue
dt2 = dt2.AddTicks (dt0.Ticks)
MsgBox (dt0.ToString & ", " & dt0.Ticks & vbCrLf _
& dt1.ToString & ", " & dt1.Ticks & vbCrLf _
& dt2.ToString & ", " & dt2.Ticks & vbCrLf)

Note that dtVar.AddTicks (23) does <not> add 23 Ticks to dtVar but
produces a new DateTime which has the sum of the Ticks.

Regards,
Fergus
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by John Hunter | last post: by
2 posts views Thread by Darren Ferguson | last post: by
1 post views Thread by Astan Chee | last post: by
5 posts views Thread by Grey Alien | last post: by
11 posts views Thread by usenet | last post: by
2 posts views Thread by Richard Rossel | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.