//計(jì)算兩個(gè)時(shí)間戳相差的時(shí)間差
public static TimeSpan GetTimeSpan(long timestamp1,long timestamp2) {
????TimeSpan ts = new TimeSpan((timestamp1 - timestamp2) * 10000000);
?????return ts;
?}?
//將時(shí)間戳轉(zhuǎn)換為日期
private static DateTime ConvertTimestampToDateTime(long timestamp)? ? {?
????TimeSpan ts = new TimeSpan(timestamp * 10000000);
?????return TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).Add(ts);
}
//將時(shí)間轉(zhuǎn)換為時(shí)間戳
????private static long ConvertDateTimeToTimestamp(System.DateTime time)? ? {
? ? return (long)(time - System.TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1))).TotalSeconds;?
?}