using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace TelpoPush.Position.Worker.Common { public class TimeHelper { /// /// 时间戳转成时间类型 /// /// /// public static DateTime ConvertToLocalDateTime(string timeStamp) { DateTime dtStart = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.Utc, TimeZoneInfo.Local); if (timeStamp.Length == 13) { long lTime = long.Parse(timeStamp + "0000"); TimeSpan toNow = new TimeSpan(lTime); return dtStart.Add(toNow); } return dtStart.AddSeconds(long.Parse(timeStamp)); } public static string ToDateTimeStr(DateTime dt) { return dt.ToString("yyyy-MM-dd HH:mm:ss"); } } }