javascript - Chrome 无法识别 24 :00:00 while Firefox does

标签 javascript jquery datetime

以下代码在 Chrome 中输出 NaN,而 Firefox 生成 1247547600000

var str = "2009/07/13 24:00:00-0500";
document.write(Date.parse(str));

查看此 fiddle .

如何解决? 谢谢!

编辑:我从另一家公司获得了数据。我无法更改它生成的数据。那么这里的建议是什么?

生成的数据:

{"day":"2009-07-13", "work":["11:16:35-12:03:12", "12:32:48-13:26:28", "13:39:09-13:39:12", "13:41:03-13:41:05", "14:18:09-24:00:00"]},
{"day":"2009-07-14", "work":["00:00:00-07:22:25", "07:22:25-07:22:28", "10:10:04-10:10:31", "10:10:32-10:15:33", "10:18:07-10:21:19", "11:04:49-11:06:15", "11:12:50-11:19:05", "11:19:11-11:19:19", "11:45:50-11:51:42", "11:51:43-11:53:55", "14:03:13-14:13:04", "14:23:55-14:31:28", "14:31:28-14:38:00", "14:38:00-14:49:04", "16:34:56-16:44:33", "16:46:37-16:48:10", "16:48:11-24:00:00"]}

最佳答案

刚遇到这个问题,研究了一下。

根据维基百科:(参见 http://en.wikipedia.org/wiki/ISO_8601)

Midnight is a special case and can be referred to as both "00:00" and "24:00". The notation "00:00" is used at the beginning of a calendar day and is the more frequently used. At the end of a day use "24:00". Note that "2007-04-05T24:00" is the same instant as "2007-04-06T00:00" (see Combined date and time representations below).

看来 Chrome 是错误的。

关于javascript - Chrome 无法识别 24 :00:00 while Firefox does,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11563870/

相关文章:

javascript - 当变量中的 .find() 项具有多个匹配项时,jQuery 出现问题

javascript - 修复侧边栏上的错误并平滑滚动

javascript - 在不使用 JavaScript 的情况下通过 iframe 访问时从页面重定向?

javascript - 如何使导航栏在单击时向左延伸? [推特 Bootstrap 3]

php - 将时间转换为可读格式

java - Joda Time - 不同时区

javascript - 使用 javascript 和父 div 自定义选择

javascript - 为什么我的 ajax 元素立即失去焦点?

javascript - 如何只为子元素运行 jQuery 函数?

C# 第二个 DateTime.ParseExact 检查第一个是否失败