PHP Program to Check a Given Year is a Leap Year or Not Last Updated : 17 Jan, 2024 Comments Improve Suggest changes Like Article Like Report A leap year is a year that is divisible by 4, except for years that are divisible by 100. However, years divisible by 400 are also considered leap years. In this article, we will explore different approaches to create a PHP program that determines whether a given year is a leap year or not. Using Conditional StatementsThe basic method involves using conditional statements to check the leap year conditions. PHP <?php function isLeapYear($year) { if (($year % 4 == 0 && $year % 100 != 0) || ($year % 400 == 0)) { return true; } else { return false; } } // Driver code $year = 2024; if (isLeapYear($year)) { echo "Leap Year"; } else { echo "Not a Leap Year"; } ?> OutputLeap YearUsing date FunctionThe date function can be utilized to determine if a given year is a leap year by checking if the 29th of February exists. PHP <?php function isLeapYear($year) { return date('L', strtotime("$year-01-01")); } // Driver code $year = 2024; if (isLeapYear($year)) { echo "Leap Year"; } else { echo "Not a Leap Year"; } ?> OutputLeap Year Comment More infoAdvertise with us Next Article R Program to Check for Leap Year V vkash8574 Follow Improve Article Tags : PHP PHP-date-time Geeks Premier League 2023 Similar Reads R Program to Check for Leap Year A leap year is a year that contains an extra day, February 29th, making it 366 days long instead of the usual 365 days. Leap years are necessary to keep our calendar in sync with the astronomical year. In the Gregorian calendar, which is the most widely used calendar system today, leap years occur i 3 min read R Program to Check for Leap Year A leap year is a year that contains an extra day, February 29th, making it 366 days long instead of the usual 365 days. Leap years are necessary to keep our calendar in sync with the astronomical year. In the Gregorian calendar, which is the most widely used calendar system today, leap years occur i 3 min read How to Categorize a Year as a Leap or Non-Leap Using VueJS? In this article, we will demonstrate the way to categorize a year as a Leap or Non-Leap using VueJS. A leap year has 366 days, whereas a non-leap year has only 365 days. We can use logic to check whether a year is a Leap or not. If a year is divisible by 400 or 4 (but not by 100) it is a leap year, 2 min read How to Categorize a Year as a Leap or Non-Leap Using VueJS? In this article, we will demonstrate the way to categorize a year as a Leap or Non-Leap using VueJS. A leap year has 366 days, whereas a non-leap year has only 365 days. We can use logic to check whether a year is a Leap or not. If a year is divisible by 400 or 4 (but not by 100) it is a leap year, 2 min read Shell Script to validate the date, taking into account leap year rules Prerequisites: Bash Scripting, Shell Function Library We will build a bash script to check whether the entered date is valid or not according to the Gregorian Calendar rules. If the date is invalid, the script will tell the reason for its invalidity. The script takes three arguments - day, month, an 5 min read How to Build a Calendar Table in PHP? In PHP, by using the Date and DateTime Functions, we can build a dynamic Calendar Table based on user input. Below are the approaches to Build a Calendar Table in PHP: Table of Content Using PHP's Date FunctionsUsing PHP's DateTime ObjectUsing PHP's Date FunctionsIn this approach, we are using PHP's 3 min read Like