/// <summary> /// 获取当前时间戳 /// </summary> /// <param name="bflag"></param> /// <returns></returns> public static string GetTimeStamp() { return GetTimeStamp(DateTime.Now); } /// <summary> /// 获取指定时间戳 /// </summary> /// <param name="date"></param> /// <returns></returns> public static string GetTimeStamp(DateTime date) { TimeSpan ts = date - new DateTime(1970, 1, 1, 0, 0, 0, 0); return Convert.ToInt64(ts.TotalSeconds).ToString(); ; } /// <summary> /// 将时间戳转换成DateTime /// </summary> /// <param name="timeStamp"></param> /// <returns></returns> private DateTime GetTime(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); }