IE 在将字符串转换为日期时删除 4 小时表单日期
IE remove 4 hours form date when convert string to date
我有 angular 应用程序,它可以与 chrome 一起正常工作,但我在 IE 中有一些小错误,其中之一是日期对象没有将其转换为正确的日期时间?在 chrome 上,它将字符串 '2015-04-09T12:30:00' 转换为 'Thu Apr 09 2015 08:30:00 GMT-0400 (Eastern Daylight Time)' 但 IE 将其转换为 'Thu Apr 09 2015 12:30:00 GMT-0400(东部夏令时) '只是想知道为什么以及如何解决它?
http://plnkr.co/edit/SBXzQe6oArXA8w3swfMo
javascript
//this line work fine in google chrome
$scope.tm = new Date(user.until);
我想这就是你的问题:
ECMAScript ed 6 draft
ECMAScript 5 ISO-8601 格式支持
The date time string may be in ISO 8601 format. For example, "2011-10-10" (just date) or "2011-10-10T14:48:00" (date and time) can be passed and parsed. The UTC time zone is used to interpret arguments in ISO 8601 format that do not contain time zone information (note that ECMAScript ed 6 draft specifies that date time strings without a time zone are to be treated as local, not UTC).
让我们比较一下 IE 和 Chrome 中的 ISO 时间。
Chrome: "2015-04-09T12:30:00.000Z"
IE:“2015-04-09T09:30:00.000Z”
IE 假设 ISO 时间是本地时间,这是应该的。
Chrome 实际上假定它的 UTC。
我有 angular 应用程序,它可以与 chrome 一起正常工作,但我在 IE 中有一些小错误,其中之一是日期对象没有将其转换为正确的日期时间?在 chrome 上,它将字符串 '2015-04-09T12:30:00' 转换为 'Thu Apr 09 2015 08:30:00 GMT-0400 (Eastern Daylight Time)' 但 IE 将其转换为 'Thu Apr 09 2015 12:30:00 GMT-0400(东部夏令时) '只是想知道为什么以及如何解决它?
http://plnkr.co/edit/SBXzQe6oArXA8w3swfMo
javascript
//this line work fine in google chrome
$scope.tm = new Date(user.until);
我想这就是你的问题: ECMAScript ed 6 draft
ECMAScript 5 ISO-8601 格式支持
The date time string may be in ISO 8601 format. For example, "2011-10-10" (just date) or "2011-10-10T14:48:00" (date and time) can be passed and parsed. The UTC time zone is used to interpret arguments in ISO 8601 format that do not contain time zone information (note that ECMAScript ed 6 draft specifies that date time strings without a time zone are to be treated as local, not UTC).
让我们比较一下 IE 和 Chrome 中的 ISO 时间。
Chrome: "2015-04-09T12:30:00.000Z"
IE:“2015-04-09T09:30:00.000Z”
IE 假设 ISO 时间是本地时间,这是应该的。 Chrome 实际上假定它的 UTC。