I am connecting to an API and one of the parameters is Long (13 digits) to hold the current timestamp
in VB.Net which represents milliseconds passed from 0:00:00 01.01.1970 in GMT
until
the current time.
The format should be like this 1290932238757
I tried this syntex :
DirectCast((Datetime.Now - New DateTime(1970, 1, 1)).TotalMilliseconds, Int64)
But the output was :
01/12/2013 02:06:24
If I understand correctly, does this work?
Dim milliseconds = CLng(DateTime.UtcNow.Subtract(New DateTime(1970, 1, 1))
.TotalMilliseconds)
I've used DateTime.UtcNow
in the example, but you can use DateTime.Now
depending on how you plan on using the data. See this thread for more information on the difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With