English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Date & Time Function Manual
The checkdate() function accepts the month, day, and year of the date as parameters and verifies whether it is Gregorian.
Check the legality of the date composed of parameters. It will be considered valid if each parameter is correctly defined.
checkdate (int $month, int $day, int $year)
Serial number | Parameters and descriptions |
---|---|
1 | month This is the integer value representing the month of the date, it must be between1to12between. |
2 | day This is the integer value representing the day of the date, it must be less than the number of days allowed in the given month. |
3 | year This is the integer value representing the year of the date, it must be between1to32767between. |
PHP checkdate() function returns a boolean value. If the given date is valid, this value istrue;If invalid, it isfalse.
This function was originally in PHP version4introduced and can be used in all higher versions.
The following examples demonstratecheckDate()Function usage-
<?php var_dump(checkdate(11, 07, 1989)); var_dump(checkdate(02, 31, 2008)); $bool = (checkdate(06, 03, 1889)); print($bool); print("\n"); print("result: ".checkdate(13, 30, 2005)); ?>Test and see ‹/›
Output result
bool(true) bool(false) 1 result:
In this example, we try to verify the date of a leap year-
<?php var_dump(checkdate(02, 30, 2004)); var_dump(checkdate(02, 28, 2008)); var_dump(checkdate(05, 31, 2020)); var_dump(checkdate(06, 31, 2020)); ?>Test and see ‹/›
Output result
bool(false) bool(true) bool(true) bool(false)
The following example verifies the date12/12/2005Is it Gregorian calendar-
<?php $bool = checkdate(12, 12, 2005); if($bool){ print("Valid date"); }else{ print("Invalid date"); } ?>Test and see ‹/›
Output result
Valid on the given date