PHP checkdate() FunctionCheck if several dates are valid Gregorian dates:
Definition
The checkdate() function can validate a Gregorian date.
Syntax
PHP checkdate() Function has the following syntax.
checkdate(month,day,year);
Parameter
Parameter | Is Required | Description |
---|---|---|
month | Required. | Month value as a number between 1 and 12 |
day | Required. | Day value as a number between 1 and 31 |
year | Required. | Year value as a number between 1 and 32767 |
Return
PHP checkdate() Function returns TRUE if the date is valid. FALSE otherwise.
Example
Validate a Gregorian date
<?php
var_dump(checkdate(2,29,2004));
var_dump(checkdate(2,31,2004));
?>
The code above generates the following result.