<分区>
Possible Duplicate:
How to convert UNIX timestamp to DateTime and vice versa?
如何在 C# 中创建 unix 时间戳? (例如 2012-10-10 14:00:00 -> 1349877600)
标签 c# date time unix-timestamp
<分区>
Possible Duplicate:
How to convert UNIX timestamp to DateTime and vice versa?
如何在 C# 中创建 unix 时间戳? (例如 2012-10-10 14:00:00 -> 1349877600)
最佳答案
private double ConvertToTimestamp(DateTime value)
{
//create Timespan by subtracting the value provided from
//the Unix Epoch
TimeSpan span = (value - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime());
//return the total seconds (which is a UNIX timestamp)
return (double)span.TotalSeconds;
}
关于c# - 如何在 C# 中生成 UTC Unix 时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12821998/