How do you convert Unix epoch time into real time in C#? (Epoch beginning 1/1/1970)
To not worry about using milliseconds or seconds just do:
public static DateTime _ToDateTime(this long unixEpochTime)
{
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
var date = epoch.AddMilliseconds(unixEpochTime);
if (date.Year > 1972)
return date;
return epoch.AddSeconds(unixEpochTime);
}
If epoch time is in seconds then there is no way you can pass year 1972 adding milliseconds.