PHP Armstrong NumberPHP Average of N NumbersPHP Biggest of Three NumbersPHP Common DivisorsPHP Composite NumberPHP Condense a NumberPHP Even NumberPHP Factorial of a NumberPHP Fibonacci SeriesPHP GCDPHP LCMPHP Leap YearPHP Multiplication TablePHP Number CombinationPHP Odd NumberPHP Palindrome NumberPHP Perfect NumberPHP Prime FactorPHP Prime NumberPHP Sum of DigitsPHP Swapping Two Numbers

PHP Array ProgramsPHP Converter ProgramsPHP Star Patterns ProgramPHP Number Patterns ProgramPHP Alphabet Patterns ProgramLast Updated:

A leap year is a calendar year containing one additional day added to keep the calendar year synchronized with the astronomical or seasonal year. For example, 2024 is a leap year.

**Tips**: It is recommended to use our online Leap Year calculator for better understanding.

To check whether a year is a leap year or not, the year should satisfy at least one of the following two conditions

- A year should be exactly divisible by 4, but, not by 100.
- A year should be exactly divisible by 4, 100 and 400 at the same time.

In the following example, we will check whether the given year (2012) is leap year or not.

PHP Compiler

<?php
$year = 2012;
if($year % 4 == 0)
{
if(($year % 100 == 0) && ($year % 400 != 0))
echo "$year is not a leap year";
else
echo "$year is a leap year";
}
else
echo "$year is not a leap year";
?>

In the following example, we will find all the Leap Years between 2000 and 2030.

PHP Compiler

<?php
$start = 2000;
$end = 2030;
$flag = 0;
echo "Leap year(s) between $start and $end: <br>";
for($start=$start; $start<=$end; $start++)
{
if($start % 4 == 0)
{
if(($start % 100 == 0) && ($start % 400 != 0))
{
// Not a leap year
}
else
{
$flag = 1;
echo "$start ";
}
}
}
if($flag == 0)
echo "There is no leap year between between the given range";
?>