Learning PHP and MySQL
Example 11-18 Validating two dates
<?php
echo("Validating: 4/31/2005<br>");
if (checkdate(4,31,2005)) {
echo('Date accepted.');
}
else {
echo ('Invalid date.');
}
echo("<br>");
echo("Validating: 5/31/2005<br>");
if (checkdate(5,31,2005)) {
echo('Date accepted.');
}
else {
echo ('Invalid date.');
}
?>
As you can tell by our example in Figure 11-15, the 31 April 2005 date was an invalid date, yet the 31 May 2005 was valid.
Posted by on 08/19 at 08:22 AM
Next entry: Example 11-19 Creating a timestamp from the components of a date
Previous entry: Example 11-17 Adding two days to the date