如何从 StackOverflow API *creation_date* 字段中检索实际日期?

How do I retrieve the actual date from the StackOverflow API *creation_date* field?

如何从 Whosebug API creation_date 字段中检索实际日期?

通过their API描述的日期是一个整数:

"creation_date": 1288523078

但是,我想将整数转换为实际的 DateTime 值。

我看到了这个link。但是我还是不太清楚。

docs所述:

All dates in the API are in unix epoch time, which is the number of seconds since midnight UTC January 1st, 1970

要转换为 .NET 日期时间,请执行以下操作:

int apiDate = 1288523078;
// `date` is UTC date here, if you need it in local timezone
//  call ToLocalTime() at the end
var date = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(apiDate);