Try our conversational search powered by Generative AI!

Scheduled jobs and daylight saving time


This has been mentioned before, f.ex. and I have seen the response by the CMS developers:

For our customer, depending on some jobs being run at a specific time of day (local time) this is a problem. I understand that the jobs run on time (UTC time) but your average web editor do not live by UTC.

I suggest you make the jobs run at the same time of the day (local time) all year. Or make it a site setting so we can choose how daylight saving time are handled regarding to schduled jobs, UTC or local time.

I do really hope I do not have to make a sheduled job that updates the NextExec column in tblScheduledItem based on daylight saving time adjustments.

May 02, 2018 8:49

ah.. date and time domain.. :) i'm tired and wish some day everyone will live in UTC

May 03, 2018 12:17

Of course with that approach you will almost certainly get jobs that are run twice a night once a year and not at all once a year. cry

May 03, 2018 17:02

Why? When a scheduled job is run, the value in the column NextExec in the database table tblScheduledItem get its value updated. 

If adjustment for daylight saving time is taken into account when NextExec is updated, this should be possible without the kind of problems you describe.

For jobs where a fixed interval (f.ex every 24hours) is required, it should still be possible to run the jobs by UTC time.

Edited, May 03, 2018 21:03

I can't see how something like this will make some jobs run twice, or not at all, once a year...

    public void RunMyScheduledJob()
        var nextExecFromDatabaseLocal = GetNextExecTime();
        // RunJobIfTimeIsInThePast(nextExecFromDatabaseLocal);
        var newNextExecTimeUTC = CalculateNextExecTime(nextExecFromDatabaseLocal, new TimeSpan(1, 0, 0, 0)); // 1 day
        // UpdateDatabaseWithNewTimeUtc(newNextExecTimeUTC);

    // Display this value in the UI, local time
    private DateTime GetNextExecTime()
        var nextExecFromDatabaseUTC = new DateTime(2018, 3, 24, 11, 0, 0, DateTimeKind.Utc); // 24. march 2018, 11:00 UTV
        var nextExecFromDatabaseLocal = nextExecFromDatabaseUTC.ToLocalTime();
        return nextExecFromDatabaseLocal;

    private DateTime CalculateNextExecTime(DateTime lastExecutedLocal, TimeSpan interval)
        var nextExecutedLocal = lastExecutedLocal + interval;
        var nextExecutedUTC = nextExecutedLocal.ToUniversalTime();
        return nextExecutedUTC;
May 04, 2018 7:47

Correct, if adjustments are done for next execution. That wasn't clear in your OP.

Now I am even more confused about what you actually request, you no longer wishes all jobs to be run in local time or having a site-setting dictating local/UTC but rather controlling it differently for each job?

May 04, 2018 14:37

I just want to schedule my jobs by local time.

That can be implemented in a number of ways. Some examples:

  • Always run jobs by local time
  • Let a global setting select local time or UTC
  • Let a setting for earch scheduled job select local time or UTC
Edited, May 05, 2018 16:18
This thread is locked and should be used for reference only.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.