datetime from unix timestamps

C# Ticks are not the same as Unix Timestamps.

Ticks are instead 1/10.000 of a millisecond. This means that we of course cannot just do

new DateTime(long ticks); //with the TimeStamp as ticks

Instead we have to do it like this.

new DateTime(1970,1,1,0,0,0,0).AddSeconds(double ourTimeStamp)

Which is actually kind of pretty.

The reason for this is of course that a unix timestamps is expressed in seconds since 01-01-1970.

Similar Posts