Skip to content
Advertisement

How can I set the new Date to 1 minute later?

I made the second argument function of the schedule run one day later through the new Date. However, I want to change it in a minute, not in a day. How do I fix the code?

this is my code

    if (user.change === true) {
      await User.update(
        { nickname: req.body.nick, change: false },

        {
          where: { id: req.user.id },
        }
      );
      const end = new Date();
      end.setDate(end.getDate() + 1); // 
      schedule.scheduleJob(end, async () => {
    
        await User.update(
          {change: true},

          {
            where: { id: req.user.id },
          }
        );

      });

Advertisement

Answer

var d = new Date();
d.setMinutes(d.getMinutes()+1);

console.log(d)
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement