C#时间转换UInt64DateTime

C#时间转换UInt64<--->DateTime


DateTime---> UInt64


DateTime currentDateTime = new DateTime();
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
UInt64 time = (UInt64)(currentDateTime - startTime).TotalMilliseconds;
--------------------------------------------------------------------------------
UInt64--->DateTime


static DateTime dt1970 = new System.DateTime(1970, 1, 1, 0, 0, 0);
        public static DateTime ConvertLongToDateTime(UInt64 d)
        {
            System.DateTime time = System.DateTime.MinValue;
            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(dt1970);
            time = startTime.AddMilliseconds(d);
            return time;
        }

你可能感兴趣的:(C#)