Skip to content

Wrong timestamp returned for getNextRun() #510

Description

@Blesmol

Hi. I've seen there are already some other bugs for this, but I also have a minimal code example for reproduction.

  • node-cron 4.2.1
  • Node 24.14.0
import cron from 'node-cron';
import Sinon from 'sinon';

Sinon.useFakeTimers(new Date('2026-03-31T09:00:01.000-02:00').getTime());

const job = cron.schedule('0 0 * * *', () => {}, { scheduled: false });

const nextRun = job.getNextRun();
console.log(nextRun);

Yesterday, the gextNextRun() gave the expected result, today in the morning it does not. Perhaps related to end of the month?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions