· 4 min read
Check If a Year Is a Leap Year
Heshan Fernando
Co-founder & COO
You’re building a date-handling feature and need to double-check whether the year you’re testing against actually has a February 29 — because “divisible by 4” is only part of the rule, and getting it wrong in code produces a real bug, not just a curiosity. Or you’re just trying to remember whether the year 2000 counted (it did, and that’s exactly the part most people get wrong).
The Gregorian leap year rule has an exception to the exception, and it’s specific enough that most people misremember it after grade school: divisible by 4 is a leap year, unless divisible by 100, unless also divisible by 400. That last clause is why the year 2000 was a leap year but 1900 wasn’t — a detail that trips up a surprising number of developers writing date logic by hand.
What checking a leap year actually involves
The full Gregorian rule: a year is a leap year if it’s divisible by 4, except years divisible by 100 are not leap years, except years divisible by 400 are leap years after all. Applying this correctly to an arbitrary year means checking all three conditions in the right order — most people (and some buggy code) stop at “divisible by 4” and get century years wrong.
Beyond a single yes/no answer, knowing the next several leap years ahead is useful context for planning purposes — anyone scheduling something years out that depends on February 29 existing needs more than just today’s answer.
Why people get stuck here
- The century exception is easy to forget. “Divisible by 4” alone gets the answer wrong for 1700, 1800, 1900, and will again for 2100.
- Writing it into code from memory. A quick
year % 4 === 0check in a script looks right and passes casual testing, but silently breaks on century years. - Confusing “leap year” with “has 366 days” in a non-standard calendar context. The Gregorian rule is the common one, but not the only calendar system with leap-day logic.
- Needing a list, not just one year. Planning something recurring around February 29 (like a “leap day only” event) needs to know several years ahead, not just whether this year qualifies.
What a good leap year checker looks like
The full, correct rule applied
Divisible by 4, except centuries, except centuries divisible by 400 — applied correctly to any year you enter, including tricky century years.
A plain-language explanation
Not just yes or no, but why — especially useful for anyone double-checking their own code or explaining the rule to someone else.
A look-ahead list
The next several leap years shown alongside the check, useful for planning purposes beyond just the single year you searched.
Common mistakes to avoid
- Writing leap year logic as
year % 4 === 0without the century exceptions, which is wrong for 1900, 2100, and any other century not divisible by 400. - Assuming every year ending in “00” is not a leap year — 2000 was one, because it’s divisible by 400.
- Forgetting the rule applies to the Gregorian calendar specifically — other calendar systems have their own, different leap-year logic.
- Hardcoding a leap year assumption into date math (like always assuming February has 28 days) instead of checking dynamically.
How to do it with Leap Year Checker
Online Tool Store’s Leap Year Checker applies the full rule instantly in your browser.
- Open the tool and enter the year you want to check.
- See whether it’s a leap year, along with a plain explanation of why.
- Review the list of the next five leap years for planning purposes.
Because the check runs instantly with no calculation required on your end, it’s a fast way to confirm a tricky century-year case without misremembering the rule yourself.
Frequently asked questions
Was the year 2000 a leap year?
Yes — even though it’s divisible by 100 (which would normally disqualify it), it’s also divisible by 400, which makes it a leap year under the full Gregorian rule.
Will 2100 be a leap year?
No — 2100 is divisible by 100 but not by 400, so it follows the century exception and will not be a leap year, unlike 2000.
Why does the leap year rule exist at all?
It corrects for the fact that Earth’s orbit takes approximately 365.2422 days, not exactly 365 — adding an extra day roughly every four years (with the century adjustments) keeps the calendar aligned with the seasons over long periods.
Final thought
The “divisible by 4” shortcut is right most of the time, which is exactly what makes the century exception so easy to forget until it actually matters — check it explicitly rather than trusting memory, especially in code.