gpt4 book ai didi

javascript - 范围错误 : Invalid time value

转载 作者:搜寻专家 更新时间:2023-10-31 23:39:44 26 4
gpt4 key购买 nike

我在启动服务器时经常遇到错误。这是错误:

RangeError:无效的时间值 在 Date.toISOString()

代码如下:

var start = timestamp;
const expiryDate = (new Date(start)).toISOString().split('T')[0];

最佳答案

当 Date 对象包含无效日期时会发生此异常。

new Date('undefined').toISOString()

在此示例中,可以毫无问题地创建 Date 对象,但 toISOString 函数会抛出错误。

要解决您的问题,您需要确保时间戳变量包含有效的日期字符串。

关于javascript - 范围错误 : Invalid time value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54462227/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com