Visit the Official PHP Website
By James N Hitz
The checkdate() function
checkdate() expects you to pass on three integers to it. These integers reperesent the month, the date and the year IN THAT ORDER. Once you have passed on these integers to checkdate(), it in turn returns TRUE or FALSE if the integers in their combination represent a valid date. The syntax is:
$valid = checkdate(month, date, year);
The variable $valid can contain one of two values: 1 (which represents TRUE) or 0 (which represents FALSE) - depending on whether the integers supplied combine to form a valid date.
So when you create a form on youer website where users are expected to enter a date, you can always use checkdate() to test whether your readers have supplied you with a valid date or not. Examples of code that will evaluate to false are:
$valid = checkdate(12,41,2001) //the date here exceeds 31 for January $valid = checkdate(14,14,1995) //the month exceeds 12 $valid = checkdate(2,29,1999) //1999 is not a leap year $valid = checkdate(4,31,1987) //April only has 30 days
See. As the above examples should set straight, the checkdate() function is one smart function because it puts into consideration dates in relation to the month and leap years. Comes in handy too.