Q. PHP Program to Check Whether the Given Year is Leap Year or Not.

Here you will find an algorithm and program in PHP to check whether the given year is leap year or not. First let us understand what is leap year?

Explanation : A leap year is a calendar year that contains an additional day added to keep the calendar year synchronized. A leap year is exactly divisible by 4, except for the century years (the years ending with 00). Century year is a leap year only if it is completely divisible by 400.

For Example : 2012 is Leap Year, 2014 is not a leap year.

Leap Year Algorithm

Step 1 → Initialize variable year
Step 3 → Check if year is divisible by 4 but not by 100, DISPLAY "leap year"
Step 4 → Check if year is divisible by 400, DISPLAY "leap year"
Step 5 → Otherwise, DISPLAY "not leap year"

PHP Program to Check Leap Year

function isLeap($check_year)  
	return (date('L', mktime(0, 0, 0, 1, 1, $check_year))==1);  
if (isLeap($check_year))  
	echo "$check_year is a Leap Year\n";  
	echo "$check_year is not a Leap Year\n";  


1998 is not a leap year.