checkdate

Validate a Gregorian date

Syntax

checkdate ( int $month , int $day , int $year ) : bool

Parameters

month

The month is between 1 and 12 inclusive.

day

The day is within the allowed number of days for the given month. Leap years are taken into consideration.

year

The year is between 1 and 32767 inclusive.

Return

Returns TRUE if the date given is valid; otherwise returns FALSE.

Examples

1

<?

$month = 2;
$day = 29;
$year = 2000;

$return = checkdate($month, $day, $year);

var_dump($return);

?>
bool(true)

2

<?

$month = 2;
$day = 29;
$year = 2001;

$return = checkdate($month, $day, $year);

var_dump($return);

?>
bool(false)

PHP

Home Menu