215 of 410 menu

The checkdate Function

The checkdate function checks the validity of a date. If such a date exists, it returns true; otherwise, it returns false.

Syntax

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

Example

Let's check the correctness of a date:

<?php var_dump(checkdate(9, 16, 2015)); ?>

Code execution result:

true

Example

Now the function is passed an incorrect date (32 December does not exist) and the function will return false:

<?php var_dump(checkdate(12, 32, 2015)); ?>

Code execution result:

false
byenru