Tuesday, March 12, 2013

C# Getting Time Since Epoch

Many things are simpler in C# than e.g. in Java, but getting the Epoch time is an exception, and this is how it's done.


TimeSpan timeSpan = DateTime.UtcNow - new DateTime(1970, 1, 1);
double currentTime = timeSpan.TotalSeconds;

No comments:

Post a Comment