1589111411 把这种转为时间类型:
两个方法都可以
/// <summary> /// 10位时间戳转为C#格式时间 /// </summary> /// <param name=”timeStamp”></param> /// <returns></returns> public static DateTime ConvertStringToDateTime(string timeStamp) { Int64 begtime = Convert.ToInt64(timeStamp) * 10000000; DateTime dt_1970 = new DateTime(1970, 1, 1, 8, 0, 0); long tricks_1970 = dt_1970.Ticks;//1970年1月1日刻度 long time_tricks = tricks_1970 + begtime;//日志日期刻度 DateTime dt = new DateTime(time_tricks);//转化为DateTime return dt; }
private DateTime StampToDateTime(string time) { time = time.Substring(0, 10); double timestamp = Convert.ToInt64(time); System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0); dateTime = dateTime.AddSeconds(timestamp).ToLocalTime(); return dateTime; }