There is this example code, but then it starts talking about millisecond / nanosecond problems. 有此示例代碼,但隨後開始談論毫秒/納秒問題。 this
The same question is on MSDN, Seconds since the Unix epoch in C# . 自M#的Unix時代以來 ,一樣的問題在MSDN上,以秒爲單位 。 spa
This is what I've got so far: 到目前爲止,這是我獲得的: .net
public Double CreatedEpoch { get { DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime(); TimeSpan span = (this.Created.ToLocalTime() - epoch); return span.TotalSeconds; } set { DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime(); this.Created = epoch.AddSeconds(value); } }