const parts = dateFormat.formatToParts(date).filter(part => { 'RangeError: Invalid time value'. at DateTimeFormat.formatToParts ()
at buidDateParts
getting error in Cron Job Scheduler using with node '20.18.3' and "node-cron": "^4.0.5". is there any Javascript date problem, i have tested with moment but same error.
cron.schedule('* * * * *', async() => {
try {
await jobScheduler.turnOffActivity();
} catch (error) {
console.log(error);
}
});
exports.turnOffActivity = async () => {
try {
const now = new Date();
const result = await Post.update(
{ is_active: false },
{
where: {
end_time: { [Op.lte]: now },
is_active: true,
type:{[Op.in]:['liveactivity','plannedactivity']}
}
}
);
} catch (error) {
console.error('Error turning off activities:', error);
}
};