How to use date Function In PHP
The 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" ; } ?> |
Leap Year
PHP Program to Check a Given Year is a Leap Year or Not
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.