gpt4 book ai didi

javascript - 如果日期不为空且日期不是 '0000-00-00' 的条件

转载 作者:行者123 更新时间:2023-11-29 16:46:16 25 4
gpt4 key购买 nike

我正在尝试用 JavaScript/PHP 编写一个 if 条件。我正在获取 datefield shipdate 的值。如果 shipdate 不为 null 或空或者 shipdate 不是 '0000-00-00' 那么 shipstatus 值应该是 'Completed' 或者 'Pending'。我没有得到正确的输出。

下面的脚本有没有错误?

if ((shipdate.getValue() !== "") && (shipdate.getValue() !== '0000-00-00'))
{
shipstatus.setValue('Completed');
} else {
shipstatus.setValue('Pending');
}

当我尝试 console.log 时,我得到一个值 '

在 console.log 中,我正在为“发货日期”获取类似“1899-11-29T18:30:00.000Z”的值。我不确定为什么?

最佳答案

在 if 语句中使用 OR 运算符代替 and 运算符

if ((shipdate.getValue() !== "") || (shipdate.getValue() !== '0000-00-00'))

关于javascript - 如果日期不为空且日期不是 '0000-00-00' 的条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41097535/

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