using System; namespace ConsoleApp13 { class Program { static void Main(string[] args) { Console.WriteLine(GetUnixTime(DateTime.Now)); Console.Read(); } /// <summary> /// 获取Unix时间戳, 秒级 /// </summary> /// <param name="dateTime">时间</param> /// <returns></returns> public static long GetUnixTime(DateTime dateTime) { DateTime start = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1, 0, 0, 0, 0)); return (long)(dateTime - start).TotalSeconds; } } }