checkdate


php apg

CHECKS 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.



  1 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(4312019); 
// April always has 30 days, no matter the year

chkdate(4292019); 

chkdate(2292016); 
// 2016 was a leap year

chkdate(2292019);

chkdate(22932764); 
// 32764 will be a leap year

chkdate(2132767); 

chkdate(1132768);
// 32768 is a value greater than the threshold 32767 

?>