Php verifies the validity of a date by using a built-in function, namely, the checkdate function. The following describes the definition and usage of the checkdate function.
Checkdate definition and usage
The checkdate () function verifies a greaguri date. If the specified value is valid, the function returns true; otherwise, false.
The date is valid in the following cases:
The month value ranges from 1 to 12.
The value of Day is within the range of days that a given month should have. A leap year has been taken into account.
Year between and includes 1 to 32767
Checkdate syntax
Checkdate (month, day, year)
Month is required. The specified month.
Day is required. Specified day.
Year is required. Specified year.
Example:
<? Phpvar_dump (checkdate (2000, 2003); var_dump (checkdate (2004,); var_dump (checkdate ));
The result will be output:
Bool (true)
Bool (false)
Bool (true)
Articles you may be interested in
- How to verify the validity of date and time using javascript
- PHP verifies the correctness and validity of the email address
- Php summarizes the methods for obtaining the time interval. php displays the time interval of Forum posts.
- PHP obtains the current time and timestamp.
- Thinkphp automatic verification and automatic filling are invalid Solutions
- Php extracts the birthday date from the ID card number and verifies whether it is a minor.
- Php summarizes the N methods used to obtain the timestamp of today, tomorrow, and yesterday
- Php obtains the start and end timestamps of today, yesterday, last week, and this month.