Often when consuming data from a web site, it will represent time with a UNIX timestamp.  This is the number of seconds since January 1, 1970.  It would be nice to turn this into a System.DateTime, but how?

DateTime FromUnixTime(Int64 unixTime)

{

DateTime time = new DateTime(unixTime * 10000000);

time = time.AddYears(1969);

return time;

}

The DateTime constructor takes the number of 100 nanosecond ticks since January 1, 0001, so multiplying by 10000000 translates seconds into 100 nanosecond intervals.  But the Unix era begins in 1970 and DateTime in 1, so to translate that we add 1969 years.