In this article, you will learn how to check if a date is valid or not. The PHP checkdate() function check if a Gregorian date is valid or invalid.
What is the syntax of the checkdate() function in PHP?
checkdate(month, day, year)
Parameters | Details |
---|---|
month | Specify the month number(1-12) – Required |
day | Specify the month number(1-31) – Required |
year | Specify the year number (1-32767)- Required |
Examples of the checkdate() function
Example 1. In this example, use checkdate() function on different Gregorian dates.
<?php
var_dump(checkdate(01,21,-300));
echo "<br>";
var_dump(checkdate(12,19,2013));
echo "<br>";
var_dump(checkdate(07,09,2021));
?>