A leap year is a calendar year that contains an additional day added to keep the calendar year synchronized with the astronomical year or seasonal year.
For example, in the Gregorian calendar, each leap year has 366 days instead of 365, by extending February to 29 days rather than the common 28. These extra days occur in each year which is an integer multiple of 4 (except for years evenly divisible by 100, which are not leap years unless evenly divisible by 400).
As now all of you know that what is Leap Year.Now let’s see how it calculate or determine that which year was or is leap year by simple few lines of code.See the below code-
<?php
$n = 2000; // user input
if($n % 4 == 0 ){
echo "Leap year";
}
else{
echo "Not a leap year";
}
Explanation :
In the above code i store year value in $n variable after that i check a condition that is there any remainder is exist or not after modulo 4 ,if no remainder then given year is a “Leap year” else it’s not a leap year.