checkdateCHECKS and
VALIDATES a
Gregorian date.
Gregorian calendar, also called New Style calendar, solar dating system now in general use.
It was proclaimed in 1582 by Pope Gregory XIII as a reform of the Julian calendar.
The introduction of the Gregorian calendar, depicted in relief on the tomb of Pope Gregory XIII in St. Peter's Basilica, Vatican City.
<?php
bool checkdate ( int $month , int $day , int $year )
where,
$mont = The number of the month
$day = The number of the day into the considered month
$year = The year
?>
$month
The number of the $month, 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
$year, between 1 and 32767, inclusive.
A date is considered valid if each parameter is properly defined.
This function returns TRUE if the date given is valid; otherwise returns FALSE.
EXERCISE
<?php
function chkdate($p1, $p2, $p3)
{
if (checkdate($p1, $p2, $p3) !== false)
{
echo 'The tested date is valid!<br><br>';
}
else
{
echo 'The tested date is NOT valid!<br><br>';
}
}
chkdate(4, 31, 2019);
// April always has 30 days, no matter the year
chkdate(4, 29, 2019);
chkdate(2, 29, 2016);
// 2016 was a leap year
chkdate(2, 29, 2019);
chkdate(2, 29, 32764);
// 32764 will be a leap year
chkdate(2, 1, 32767);
chkdate(1, 1, 32768);
// 32768 is a value greater than the threshold 32767
?>