RangeError: invalid date

翻译正在进行中。

Message

范围错误: 非法数据(Firefox)
范围错误: 非法时间值 (Chrome)
范围错误: 提供的数据不是有效的 (Chrome)

Error type

RangeError

What went wrong?

A string leading to an invalid date has been provided to Date or Date.parse().

Examples

Invalid cases

Unrecognizable strings or dates containing illegal element values in ISO formatted strings usually return NaN. However, depending on the implementation, non–conforming ISO format strings, may also throw RangeError: invalid date, like the following cases in Firefox:

new Date('foo-bar 2014');
new Date('2014-25-23').toISOString();
new Date('foo-bar 2014').toString();

This, however, returns NaN in Firefox:

Date.parse('foo-bar 2014'); // NaN

For more details, see the Date.parse() documentation.

Valid cases

new Date('05 October 2011 14:48 UTC');

See also

文档标签和贡献者

 此页面的贡献者: dudusky
 最后编辑者: dudusky,