铬间$ P $点ISO时间是无Z为UTC; C#问题 [英] Chrome interprets ISO time without Z as UTC; C# issue

查看:90
本文介绍了铬间$ P $点ISO时间是无Z为UTC; C#问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行此的jsfiddle: http://jsfiddle.net/E9gq9/7/ 在Chrome,FF和IE浏览器和您可以:

浏览器:

火狐:

IE:

Safari浏览器:

ISO 8601 不会出现说没有尾随Z A字符串​​应该如何跨preTED。

我们的服务器(ASP.NET MVC4)是拉动UTC时间我们的数据库为的DateTime 和简单的馅他们JSON。正如你所看到的,因为这一点,我们在浏览器上得到不一致的结果。

难道只追加Z到他们在服务器端?


解决方案

  

铬间$ P $点ISO时间是无Z为UTC; C#问题


这是正确的,它的Firefox和IE的越来越理解错了。

当你链接的文章确实说的是什么意思时,有没有以Z 如果没有UTC相关信息,用时再$ P $定psentation,时间被假设为在本地时间。的),更重要的是,在 ECMAScript5规范说很清楚,没有时区信息化手段以Z


  

缺席时区偏移的值是Z。


是的,我很可能会确保字符串有一个以Z 就可以了,因为这似乎给你一致的结果。

Run this jsfiddle: http://jsfiddle.net/E9gq9/7/ on Chrome, FF, and IE and you get:

Chrome:

Firefox:

IE:

Safari:

ISO 8601 does not appear to say how a string without a trailing Z should be interpreted.

Our server (ASP.NET MVC4) is pulling UTC times out of our database as DateTimes and simply stuffing them in JSON. As you can see because of this we are getting inconsistent results on the browser.

Should we just append Z to them on the server side?

解决方案

Chrome interprets ISO time without Z as UTC; C# issue

Which is correct, it's Firefox and IE that are getting it wrong.

While the article you linked does indeed say what it means when there's no Z ("If no UTC relation information is given with a time representation, the time is assumed to be in local time."), the more important thing is that the ECMAScript5 specification says quite clearly that no timezone information means Z:

The value of an absent time zone offset is "Z".

Yes, I would probably ensure the string has a Z on it, as that seems to give you consistent results.

这篇关于铬间$ P $点ISO时间是无Z为UTC; C#问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆