如何在 Javascript 中将 Date 对象设置为 null?

How can I set Date object to null in Javascript?

我正在尝试将 check_date 设置为 null 我试过了

new Date as 0, null


但其中 none 为我工作。我怎样才能做到这一点?

代码

  async lastDayToLive() {
        const allDiner  = await this.amazon.findAll({ where: { flight: 'L' } });
        const len = allDiner .length;
        const lastDinker = allDiner [len - 1];
        const { a,} = lastDinker;
        await this.amazon.update(
            { flight: 'land', check_date: `${new Date(0)}` }, --------------------> Here
            { where: {a}}
        );

        
    }

您不能将日期设置为 null。日期是 embedded JavaScript type.

将日期设置为 new Date(0) 只是将其设置为 Unix Epoch

但是,您可以将变量设置为 null

这应该有效:

var check_date = null;

或者,在您的情况下:

        await this.amazon.update(
            { flight: 'land', check_date: null }, 
            { where: {a}}
        );