我有一些JSON被返回...我如何使用c#和JS格式化这些日期时间字符串?
{
"time": 1469257200,
"summary": "Partly cloudy in the morning.",
"icon": "partly-cloudy-day",
"sunriseTime": 1469279237,
"sunsetTime": 1469330841,
"moonPhase": 0.63,
...... ..... ...
},
欢迎帮助!!!
答案 0 :(得分:0)
很容易:
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;
}