#region 时间,时间戳转换
/// <summary>
/// 时间转换为事件戳
/// </summary>
/// <param name="dateTime"></param>
/// <returns></returns>
public static uint GetTimeStamp(DateTime dateTime)
{
DateTime DateStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
return Convert.ToUInt32((dateTime - DateStart).TotalSeconds);
}
/// 时间戳转为C#格式时间
/// </summary>
/// <param name=”timeStamp”></param>
/// <returns></returns>
public static DateTime GetTimeFromUint(string timeStamp)
{
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);
}
#endregion