I have developped a PocketPC application with CF and VB.net. Now there
are some new features to implement and in one case I have to send a
request to a WebService with several arguments and one of them is the
current date in an unix format (seconds since 01.01.1970).
Is there a possibility or an existing function to convert the current
date (now()) to this date/time format? Has someone an existing code
snipplet for this?
Thanks in advance,
Marko
Something like:
Dim d As DateTime = DateTime.Now
Dim ts As TimeSpan = d.Subtract(#1/1/1970#)
Dim secs As Integer = CInt(ts.TotalSeconds)
To convert a "unix format" back to DateTime you can simply add the seconds
to 1/1/70
d = #1/1/1970#.AddSeconds(secs)
Note #1/1/1970# is a date literal, which is always month, day, year
independent of the current local...
I was thinking .NET had a 'function' to do this, however I am not seeing it
right now...
Hope this helps
Jay
"Marko Maehner" <marko....@gmx.de> wrote in message
news:7a8ae685.04031...@posting.google.com...
Dim ts as TimeSpan = (DateTime.UtcNow - new DateTime(1970,1,1,0,0,0));
Dim unixTime as Double = ts.TotalSeconds;
Unix To .NET
(new DateTime(1970,1,1,0,0,0)).AddSeconds(unixtimestamp)
hth
Richard