Home >Backend Development >PHP Tutorial >How to use php checkdate function
The checkdate function is a built-in function of PHP. Its syntax is "checkdate(month, day, year)", which is used to verify a Gregorian date and check the legality of the date composed of parameters.
Recommended: "PHP Video Tutorial"
The checkdate() function is a built-in function of PHP , the syntax is checkdate(month,day,year), used to verify a Gregorian date and check the legality of the date composed of parameters. Each parameter is considered valid if it is defined correctly.
How to use php checkdate() function?
Function: Verify a Gregorian date
Syntax:
checkdate(month,day,year)
Parameters:
month Required. Specifies the month, a numeric value from 1 to 12.
day Required. Specifies the day, a numeric value from 1 to 31.
year Required. Specifies the year, a numeric value from 1 to 32767.
Return value: This function returns a Boolean value. Returns true if the date is a valid date, false otherwise.
Description: Check if some dates are valid Gregorian dates.
php checkdate() function example
<?php var_dump(checkdate(12,31,-220)); echo "<br>"; var_dump(checkdate(2,29,2003)); echo "<br>"; var_dump(checkdate(2,29,2004)); ?>
Output:
bool(false) bool(false) bool(true)
This article is about the use of checkdate function. I hope it will help those who need it. Friends help!
The above is the detailed content of How to use php checkdate function. For more information, please follow other related articles on the PHP Chinese website!