Unix时间戳与C# DateTime时间类型互换
时间:2011-01-26 来源:MicroCoder
/// <summary> /// method for converting a System.DateTime value to a UNIX Timestamp /// </summary> /// <param name="value">date to convert</param> /// <returns></returns> 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; }
相关阅读 更多 +