EPOCH Time

S

Sunil

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
 
H

Herfried K. Wagner [MVP]

Hello,

Sunil said:
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
 
F

Fergus Cooney

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
 

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

Top