遇到Unix时间戳转换的问题,遂记录下来。

Unix时间戳转DateTime

string UnixTime = "1474449764"; //时间戳
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
DateTime TranslateDate = startTime.AddSeconds(double.Parse(UnixTime));

DateTime转Unix时间戳

//DateTime转Unix时间戳
DateTime DateNow = DateTime.Now;
long UnixDate= (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;

附:这是一个时间戳的转换网址,上面也有不同语言的转换。

http://unixtime.51240.com/

相关文章:

  • 2021-07-23
  • 2022-02-02
  • 2022-12-23
  • 2022-12-23
  • 2022-01-29
  • 2022-12-23
  • 2021-07-28
猜你喜欢
  • 2021-11-22
  • 2022-02-24
  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案