下面的两个 JSON 值(created、udated)是某种类型的时间戳。提供者(Edmunds API)除了“时间戳”之外没有指定任何内容。我已尝试将标准 UNIX 转换为 .Net Datetime,但没有任何效果。
“创建”:1380292641721,“更新”:1380312585558
以下两种方法无效:
internal DateTime ConvertUnixEpochTime(long epoch)
{
long baseTicks = 621355968000000000;
long tickResolution = 10000000;
//long epoch = 1225815911;
long epochTicks = (epoch * tickResolution) + baseTicks;
return new DateTime(epochTicks, DateTimeKind.Utc);
}
public DateTime UnixTimeStampToDateTime(long unixTimeStamp)
{
// Unix timestamp is seconds past epoch
System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();
return dtDateTime;
}
有什么建议么?