I am wondering if .NET contains a method to convert the current time in seconds or milliseconds to a UNIX timestamp (offset from 1970/1/1)?
you can get the ticks from 1970 (ie the UNIX timestamp) like this:
TimeSpan timeSpan = DateTime.UtcNow - new DateTime(1970,1,1,0,0,0);
double unixVersion = timeSpan.TotalSeconds;
TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1));
Console.WriteLine((int)t.TotalSeconds);
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