• Post category:PHP

Checkdate Function in PHP | Explained

Checkdate in PHP

PHP checkdate() is a useful built-in function, which accepts a month, day, and year (mm/dd/yyyy) combination and returns a true/false value indicating whether the corresponding date is valid.

<?php
if(checkdate(2, 13, 2022))
echo 'Date is valid';
else
echo 'Date is invalid';
echo "<br/>";

if(checkdate(2, 30, 2022))
echo 'Date is valid';
else
echo 'Date is invalid';
?>

Output:

checkdate in php

Here, we check whether the date is valid or not using the PHP check date () function. It returns true, if the given date is valid otherwise it returns false.

More about >> dates in PHP

Leave a Reply