PHP checkdate() Function
In this chapter you will learn:
- Definition for PHP checkdate() Function
- Syntax for PHP checkdate() Function
- Parameter for PHP checkdate() Function
- Return value from PHP checkdate() Function
- Example - validate a Gregorian date
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.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP date() Function
- Syntax for PHP date() Function
- Parameter for PHP date() Function
- Return value for PHP date() Function
- Example - prints out the current time in 24-hour clock format
- Example - This next example outputs the date in the format of 31st of August 2012
Home » PHP Tutorial » PHP Date Functions