WRLD CLOCKBack to clock

Guide

How the day of the week is worked out

The integer arithmetic behind the day-of-the-week calculator: the proleptic Gregorian calendar, the leap-year rule, and day counts between dates.

The date alone decides the weekday

The day of the week tool takes a year, a month and a day and returns the weekday. The calendar engine is proleptic Gregorian and computed with integer arithmetic, so it is independent of the platform date object, the local time zone and the two-digit-year quirk: a date maps to the same weekday whoever runs it, whenever they run it.

On three fixed dates the long form reads Thursday, July 4, 1776; Saturday, January 1, 2000; Friday, March 2, 2035. The 7 days from 2024-01-01 come back as Monday, January 1, 2024; Tuesday, January 2, 2024; Wednesday, January 3, 2024; Thursday, January 4, 2024; Friday, January 5, 2024; Saturday, January 6, 2024; Sunday, January 7, 2024: one of each weekday, in order.

The only thing the tool reads from the device is today's date, so it can open on today and highlight it — a described behaviour, not one this guide can simulate. Every “today” below is a fixed stand-in, Sunday, August 9, 2026, so the figures are the same on every build.

Sakamoto’s algorithm, step by step

The weekday comes from a short piece of arithmetic known as Sakamoto's algorithm, which is correct for any year in the proleptic Gregorian calendar. If the month is January or February, the date is counted as belonging to the previous year, so that a leap day — when the year has one — sits at the end of the year being counted rather than part-way through it. To that year the function adds the year divided by four, subtracts the year divided by one hundred and adds the year divided by four hundred, each rounded down: together, the number of leap days the Gregorian rule has inserted up to that point. It then adds a fixed offset for the month, from a table of 12 entries built into the function, and the day of the month. The remainder of that sum on division by 7 is the weekday index.

The index is a position in the engine's weekday list, which runs 0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday. On the three dates above the function returns 4 for 1776-07-04 (Thursday), 6 for 2000-01-01 (Saturday), 5 for 2035-03-02 (Friday). Because the index is a remainder on division by 7, stepping a date forward by 7 days lands on the same weekday — 1776-07-04 plus 7 days is a Thursday again — while a single day forward is a Friday.

Leap years and the length of a month

Leap years follow the full Gregorian rule: divisible by four, except centuries, unless divisible by four hundred. The engine applies that rule and nothing else. Checked at build time: 2000 is a leap year, so its February has 29 days; 1900 is a common year, so its February has 28 days; 2024 is a leap year, so its February has 29 days; 2023 is a common year, so its February has 28 days.

The leap day shifts everything that follows it. The engine's day-of-year count, which the tool shows beneath the weekday, puts 2024-03-01 at day 61 of its year but 2023-03-01 at day 60 of its own; the last day of 2024 is day 366 and the last day of 2023 is day 365.

The same shift is why a weekday moves by a different amount from one year to the next. From 2023-03-01 to 2024-03-01 is 366 days, a remainder of 2 on division by 7, so the weekday moves from Wednesday to Friday. From 2024-03-01 to 2025-03-01 is 365 days, a remainder of 1, so the weekday moves only to Saturday.

Day counts are differences of Julian Day Numbers

The engine does not count days by walking month lengths. It converts each date to a Julian Day Number — a continuous integer count of days, with no months, years or leap rules left in it — and subtracts. A count between two dates is one subtraction; adding days to a date is one addition and the inverse conversion back to a year, month and day.

From 2024-02-28 to 2024-03-01 the engine counts 2 days, because the leap day lies between them; from 2023-02-28 to 2023-03-01 it counts 1. From Thursday, May 17, 1990 to the stand-in today it counts 13,233 days, and adding exactly that many days back onto the birth date returns 2026-08-09, which is the stand-in today: the two operations are inverses of each other.

The count is signed: reverse the two dates and the engine returns -13,233; from a date to itself it returns 0. Adding 1 day to 2024-12-31 gives 2025-01-01; 1 day before 2024-03-01 is 2024-02-29, while 1 day before 2023-03-01 is 2023-02-28. Month and year boundaries need no special handling, because the integer count has none.

How to read the readout

The large word is the weekday. Beneath it is the long form of the date — Thursday, May 17, 1990for the birth date above — and beneath that a quieter line assembled from three engine calls: a relative phrase, a day-of-year count and a line of a traditional verse. For that date, with the stand-in today, it reads “13,233 days ago · day 137 of 1990 · Thursday’s child is far to go”.

Measured from the stand-in today, the relative phrase gives:

  • 2026-08-09 (the stand-in today itself): “Today”
  • 2026-08-10 (1 day on): “Tomorrow”
  • 2026-08-08 (1 day back): “Yesterday”
  • 2026-08-19 (10 days on): “in 10 days”
  • 2026-07-30 (10 days back): “10 days ago”
  • 2035-03-02 (the March date in 2035): “in 3,127 days”

A phrase ending in “ago” is a negative day count read aloud; one beginning with “in” is a positive count. On the live tool the phrase is measured from the device's own date, so it changes from one day to the next; the weekday, the long form and the day-of-year count never do.

The month grid

The calendar beneath the readout is a full rectangle of 42 cells — 6 rows of 7 — for whichever month is in view, with the spill days from the adjacent months included so that every grid is the same shape. The grid builder defaults to a Sunday-first week and the tool keeps that default; the weekday of a date does not change with that choice, only the column it sits in.

For August 2026, whose first day is a Saturday, the grid opens with 6 cells from July, then the 31 days of August, and closes with 5 cells from September. Each cell is one day after the previous one; a check across the whole grid at build time confirms it.

Month navigation is a smaller piece of arithmetic that rolls the year at both ends: one month on from December 2024 is January 2025, one month back from January 2024 is December 2023, and 12 months on from August 2026 is August 2027.

Typing a date

A typed date is parsed as year, month and day and validated against the engine's own month lengths; a value that would overflow its month is rejected rather than rolled into the next month. The 4 fixed strings below, put through the parser at build time, come back as:

  • 2024-02-29: accepted as Thursday, February 29, 2024
  • 2023-02-29: rejected
  • 2024-04-31: rejected
  • 2026-08-09: accepted as Sunday, August 9, 2026

Dates are written back the same way, zero-padded to a four-digit year: the Fourth of July in 1776 is 1776-07-04.

The verse

The last item on the quiet line is the traditional Monday's Child line for the weekday, keyed in the engine by weekday index. It is a public-domain English folk rhyme, not a horoscope — the thing most people are half-remembering when they ask what their birth day means. Read straight from the engine:

  • Sunday’s child is bonny and blithe, and good and gay
  • Monday’s child is fair of face
  • Tuesday’s child is full of grace
  • Wednesday’s child is full of woe
  • Thursday’s child is far to go
  • Friday’s child is loving and giving
  • Saturday’s child is works hard for a living

Where the calculation stops

The engine is proleptic Gregorian: it applies today's calendar rules to every date, including dates before those rules were in use. Before a country adopted the Gregorian calendar, the weekday people wrote down could differ from the one shown here. Britain and its American colonies switched in September 1752, dropping eleven days to catch up; Russia did not switch until 1918. For dates in that era the calculator gives the Gregorian weekday, which is the modern convention and the one used to date historical events, but it is not what a diary of the day would necessarily have said.

Nothing here depends on the time zone, because nothing here involves a time: a date is three integers and the arithmetic never turns them into an instant, so the weekday of a date you pick is the same on every device. The whole calculation runs in the browser from the date you pick, and no date is sent anywhere.

Questions

Why does the weekday not depend on my time zone?
Because the calculation never involves a time. The engine takes the year, month and day as integers and runs Sakamoto's algorithm on them; no instant, clock or zone enters the arithmetic, so the same date gives the same weekday on every device.
Is 1900 a leap year? Is 2000?
The engine applies the full Gregorian rule — divisible by four, except centuries, unless divisible by four hundred — and reports that 1900 is not a leap year and 2000 is a leap year. That rule, and nothing else, decides whether a February has 28 or 29 days.
Why is the day count across the end of February sometimes one more than I expected?
Because a leap day may lie between the two dates. From 2024-02-28 to 2024-03-01 the engine counts 2 days; from 2023-02-28 to 2023-03-01 it counts 1. The count is a difference of Julian Day Numbers, so every day between the two dates is included whether or not it exists in other years.
What does "day 61 of 2024" mean on the readout?
It is the position of the date within its year, counting the first of January as day 1. 2024-03-01 is day 61 of 2024 because January, February and the first of March add up to that many days in a leap year; in 2023 the same calendar date is day 60.
Why does an old date's weekday look wrong to me?
The calculator uses the Gregorian calendar for every date. Countries adopted it at different times — Britain and its colonies in 1752 — so for dates before then the historical Julian weekday can differ. The Gregorian weekday shown is the modern standard used to date historical events.
Can I count the days to a date in the future?
Yes. The day count is a signed subtraction, so a later date gives a positive number and the readout phrases it as "in … days": from the fixed stand-in today used in this guide, 2035-03-02 reads "in 3,127 days". On the live tool the count is measured from the device's own date, so it falls by one each day.

Everything here runs in your browser: the figures above were computed from the engine when the site was built, and the timers themselves run on this device's own clock. The methodology page describes the whole engine, and the guides index lists the other guides.