当我意识到这是一个unix时间戳时,
我返回了一些JSON。。。如何使用c#和JS格式化这些日期时间字符串?
{
"time": 1469257200,
"summary": "Partly cloudy in the morning.",
"icon": "partly-cloudy-day",
"sunriseTime": 1469279237,
"sunsetTime": 1469330841,
"moonPhase": 0.63,
...... ..... ...
},
感谢您的帮助!!!
就很容易了:
public static DateTime UnixTimeStampToDateTime(double unixTimeStamp)
{
// Unix timestamp is seconds past epoch
System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();
return dtDateTime;
}