How to generate a UTC Unix Timestamp in C#
本问题已经有最佳答案,请猛点这里访问。
Possible Duplicate:
How to convert UNIX timestamp to DateTime and vice versa?
号
如何在C_中创建Unix时间戳?(如2012-10-10 14:00:00->1349877600)
1 2 3 4 5 6 7 8 9 | private double ConvertToTimestamp(DateTime value) { //create Timespan by subtracting the value provided from //the Unix Epoch TimeSpan span = (value - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()); //return the total seconds (which is a UNIX timestamp) return (double)span.TotalSeconds; } |