Chrome无法识别24:00:00 [英] Chrome not recognizing 24:00:00 while Firefox does

查看:129
本文介绍了Chrome无法识别24:00:00的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

The following code outputs outputs NaN in Chrome while Firefox generates 1247547600000.

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

看到这个 小提琴

如何解决?
谢谢!

How to solve this? Thank you!

编辑:我收到了另一家公司的数据。我无法更改其生成的数据。那么这里有什么建议?

I've got the data from another company. I cannot change the data it generates. So What are the suggestions here?

生成的数据:

{"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"]}


推荐答案

您正在要求浏览器解析无效的时间。 24:00无效。你可能意味着第二天的0点。 Chrome拒绝它是正确的。 Firefox只是更宽容。

You are asking the browser to parse an invalid time. 24:00 isn't valid. You probably mean 0:00 of the next day. Chrome is correct in rejecting it. Firefox is simply more forgiving.

考虑一天中有24小时。如果第一个小时是00,那么最后一小时是23。

Consider that there are 24 hours in the day. If the first hour is 00, then the last hour is 23.

这篇关于Chrome无法识别24:00:00的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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