Parsing UNIX timestamps with VB.NET

  • Thread starter Thread starter Mitchell Vincent
  • Start date Start date
M

Mitchell Vincent

Would anyone happen to have any idea how to get a UNIX timestamp (AKA
epoch, or number of seconds since Jan 1st 1970) into a VB.NET datetime
type? I have a legacy application I'm trying to port and all the dates
and times are stored in the UNIX format..

Thanks!
 
Just add seconds in the epoch date

dim dt as Date = #1/1/1970#.AddSeconds(10327314­19)
or
dim dt as Date = new System.DateTime (1970,1,1).AddSeconds(10327314­19)

P.S.where 10327314­19 is the epoch seconds
P.S.code not compiled

HTH
rawCoder
 
Would anyone happen to have any idea how to get a UNIX timestamp (AKA
epoch, or number of seconds since Jan 1st 1970) into a VB.NET datetime
type? I have a legacy application I'm trying to port and all the dates
and times are stored in the UNIX format..

Thanks!

So, your dates are stored as seconds since the epoch? Then you should
be able to do something like:

Private ReadOnly EPOCH As Date = New Date (1970, 1, 1)

Dim theDate As Date = EPOCH.AddSeconds (SecondsSinceEpoch)
 
Tom said:
So, your dates are stored as seconds since the epoch? Then you should
be able to do something like:

Private ReadOnly EPOCH As Date = New Date (1970, 1, 1)

Dim theDate As Date = EPOCH.AddSeconds (SecondsSinceEpoch)

Doh. Now why didn't I think about that..

Thanks guys!!!
 

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

Back
Top