如何将UNIX时间戳转换为.NET System.DateTime对象

・1 分钟阅读


// Example of a UNIX timestamp for 11-29-2013 4:58:30
double timestamp = 1385701110;

// Format our new DateTime object to start at the UNIX Epoch
System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);

// Add the timestamp (number of seconds since the Epoch) to be converted
dateTime = dateTime.AddSeconds(timestamp);
Jiaoyang75 profile image