Moment.js在Firefox中返回NaN但不返回chrome [英] Moment.js returning NaN in Firefox but not chrome
问题描述
我有以下代码行:
moment("11-10-2013 09:03 AM").diff(moment(),"minutes");
在Chrome 30.0.1599.101中,以下行返回一个数字(它将每分钟更改,所以确切值不相关)。
In Chrome 30.0.1599.101, the following line return a number (It will change every minute so the exact value is not relevant).
在Firefox 25.0中,它返回 NaN
。
In Firefox 25.0, it returns NaN
.
我正在使用moment.js 2.4.0。
I am using the moment.js 2.4.0.
有谁理解为什么这在Chrome中运行而不是FF?我有一种感觉它与Chrome和Firefox解析日期字符串的方式有关,但是我无法确切地说明原因。
Does anyone understand why this works in Chrome and not FF? I have a feeling it has to do with the way Chrome and Firefox parse date string, but haven't been able to put my finger on the exact reason.
推荐答案
Date.parse(11/10/2013 09:03 AM)
或 Date.parse(11 10 2013 09:03 AM)
似乎在firefox中运行。 Chrome似乎更容易使用分隔符,允许。
, -
,甚至;
但标准是什么只能通过查看规格来判断。
Date.parse("11/10/2013 09:03 AM")
or Date.parse("11 10 2013 09:03 AM")
seem to work in firefox. Chrome seems to be more permissible with delimiters, allowing .
, -
, and even ;
but what's standard it'll only be possible to tell by looking at specifications.
这篇关于Moment.js在Firefox中返回NaN但不返回chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!