unix时间戳:单位是秒
毫秒时间戳:单位是毫秒
毫秒时间戳 = unix时间戳 * 1000
public static DateTime ConvertStampToTime(long timeStamp) { if (timeStamp.ToString().Length == 13) { timeStamp = timeStamp / 1000; } DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); long lTime = long.Parse(timeStamp + "0000000"); TimeSpan toNow = new TimeSpan(lTime); return dtStart.Add(toNow); } public static long ConvertTimetoStamp(System.DateTime time) { return (time.ToUniversalTime().Ticks - 621355968000000000) / 10000; }