示例#1
0
        /// <summary>
        /// 获取Unix时间戳
        /// </summary>
        /// <param name="time">时间</param>
        public static long GetUnixTimestamp(DateTime time)
        {
            var  start = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.Local);
            long ticks = (time - start.Add(new TimeSpan(8, 0, 0))).Ticks;

            return(Converts.ToLong(ticks / TimeSpan.TicksPerSecond));
        }
示例#2
0
 /// <summary>
 /// 设置时间
 /// </summary>
 /// <param name="dateTime">时间</param>
 public static void SetTime(string dateTime)
 {
     _dateTime = Converts.ToDateOrNull(dateTime);
 }