//计算两个时间戳相差的时间差
public static TimeSpan GetTimeSpan(long timestamp1,long timestamp2) {
TimeSpan ts = new TimeSpan((timestamp1 - timestamp2) * 10000000);
return ts;
}
//将时间戳转换为日期
private static DateTime ConvertTimestampToDateTime(long timestamp) {
TimeSpan ts = new TimeSpan(timestamp * 10000000);
return TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).Add(ts);
}
//将时间转换为时间戳
private static long ConvertDateTimeToTimestamp(System.DateTime time) {
return (long)(time - System.TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1))).TotalSeconds;
}