问题描述
我的WCF web服务返回C#的DateTime对象为JSON这样,
日期(1293793200000 + 1300)/
我发现这一点,
的
这表明这种方法使用JavaScript将它转换,
变种D =新的日期();
d.setTime(1245398693390);
的document.write(D);
不同的是,我的日期格式有它的+ 1300,这似乎是我的时区,因为我是从格林尼治标准时间13小时。
我可以以某种方式修改我的服务的价值调整从时代毫秒的绝对数量还是可以的JavaScript修改
您可以忽略时区偏移 - 毫秒数总是相对于UTC(请参见日期时间线格式部分在)。偏移量大多表示原始的DateTime
值 DateTimeKind.Local
的,但由于时代序列化毫秒总是相对于GMT
My WCF webservice is returning C# DateTime objects as JSON like this,
"/Date(1293793200000+1300)/"
I have found this,
Converting .NET DateTime to JSON
Which suggests this method for converting it using javascript,
var d = new Date();
d.setTime(1245398693390);
document.write(d);
The difference is that my date format has the +1300 in it, which seems to be my timezone, as I am +13 hours from GMT.
Can I somehow modify my service to adjust the value to an absolute number of milliseconds from epoch or can the javascript be modified?
You can ignore the time zone offset - the number of milliseconds is always relative to UTC (see the "DateTime wire format" section at http://msdn.microsoft.com/en-us/library/bb412170.aspx). The offset mostly indicates that the original DateTime
value was of DateTimeKind.Local
, but the serialized milliseconds since the epoch is always relative to GMT.
这篇关于如何转换.NET日期时间为JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!