Command Palette

Search for a command to run...

Time & Date

Every Time & Date tool on Toolz.dev: 4 free utilities that run entirely in your browser. No signup, no uploads, no downloads.

Two different problems live in this category. Scheduling is one: writing a cron expression that runs a job when you meant, and reading one that someone else wrote. Measuring is the other: how long between two dates, and how long between two times, which sound trivial until months of different lengths and clocks that go backwards are involved.

Both are unusually easy to get wrong quietly. A cron expression that is off by one field runs at the wrong hour every day without error, and a duration calculated across a daylight saving change is an hour out in a way nobody notices until it appears on an invoice.

Which time tool for which question

Which time tool for which question
QuestionToolNotes
When will this schedule run?Cron Expression ParserPlain English, plus the next run times
How do I write this schedule?Cron Expression GeneratorBuilds the 5 fields from a description
How long between two dates?Date Difference CalculatorYears, months, days, and business days
How long between two times?Time Duration CalculatorAdds and subtracts hours and minutes too

Reading a cron expression

Standard cron has five fields, in order: minute, hour, day of month, month, day of week. Everything else is built from four symbols. An asterisk means every value. A comma lists values, so 1,15 is the first and fifteenth. A hyphen gives a range, so 9-17 is nine to five. And a slash gives a step, so */5 in the minute field is every five minutes. That is the whole language, which is why the cron parser can turn any valid expression into a sentence.

Two variations cause most of the confusion. Some systems, notably Quartz and several cloud schedulers, take six fields by putting seconds first, so a five-field expression pasted into one runs at an unintended time. And the day-of-month and day-of-week fields are combined with OR, not AND, when both are restricted: 0 0 1 * 1 runs on the first of the month and on every Monday, not on Mondays that fall on the first. That rule is inherited from the original Unix implementation and surprises people every time.

What cron does not know

A cron expression carries no time zone. The schedule runs in whatever zone the machine or the scheduler is configured for, which is why the same expression fires at different wall-clock times on a laptop and on a server in UTC. Daylight saving makes that concrete twice a year: when clocks go forward, a job scheduled inside the skipped hour may not run at all, and when they go back, a job in the repeated hour may run twice. If a job must not double-run, either schedule it in UTC or make it idempotent.

The related limit is that cron has no memory. If the machine was asleep or the service was down at the scheduled moment, the run is simply missed - there is no catch-up unless something like anacron provides it. For anything where a missed run matters, the schedule is the trigger and the job itself has to check what work is outstanding.

Why date arithmetic disagrees with itself

Asking how many months lie between two dates has more than one defensible answer, because months are not a fixed length. From 31 January to 28 February is one month by every calendar convention and 28 days by counting. Add one month to 31 January and you get 28 February in most libraries, which means adding a month and then subtracting one does not return you to where you started. The date difference calculator reports years, months and days as a calendar breakdown and the total in days separately, because the two answer different questions.

Business days are a second convention rather than a fact. The calculator counts Monday to Friday and excludes weekends, which is the common definition, but public holidays vary by country and even by region within one, so a jurisdiction-specific count needs a holiday list layered on top. For elapsed time within a day, the duration calculator handles the crossing-midnight case that catches manual arithmetic, and can add or subtract hours and minutes from a starting time.

Frequently asked questions

What do the five fields in a cron expression mean?
Minute, hour, day of month, month, day of week, in that order. An asterisk means every value, a comma lists values, a hyphen gives a range and a slash gives a step, so 0 9 * * 1-5 is nine in the morning on weekdays. Some schedulers, including Quartz, add a seconds field at the front and take six.
Why does my cron job run more often than expected?
Most likely because day of month and day of week are combined with OR when both are restricted. The expression 0 0 1 * 1 runs on the first of every month and on every Monday, not only on a Monday that falls on the first. This behaviour comes from the original Unix cron and is shared by nearly every implementation.
Does cron handle daylight saving time?
Not on its own. A cron expression has no time zone and runs in the zone the machine is set to, so when clocks go forward a job inside the skipped hour may not run, and when they go back a job in the repeated hour may run twice. Scheduling in UTC or making the job idempotent are the two reliable answers.
How do I run a job every five minutes?
Use a step value in the minute field: */5 * * * *. The same form works elsewhere, so 0 */2 * * * is every two hours on the hour. Avoid listing minutes by hand, since a comma-separated list is easy to get wrong and impossible to skim.
How are business days counted?
Monday to Friday, excluding Saturday and Sunday. Public holidays are not deducted, because they differ by country and often by region within one, so a legally exact count needs a holiday calendar for the specific jurisdiction layered on top of the weekday count.
Why do date calculators disagree about the number of months?
Because months have different lengths, so a calendar difference and a day count are genuinely different answers. From 31 January to 28 February is one month or 28 days depending on which you ask for, and adding a month then subtracting one does not always return the original date. The calculator reports both breakdowns rather than picking one.