Date_Calc::isValidDate
| From: | Pierre-Alain Joye | Date: | Tue, 11 Jun 2002 12:31:30 +0000 |
| Subject: | Date_Calc::isValidDate | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-6924@lists.php.net to get a copy of this message | ||
Hello,
Please find a may easier DateCalc::isValidDate method :
function isValidDate($day, $month, $year)
{
if($year < 0 || $year > 9999)
return false;
if(!checkdate($day,$month,$year))
return false;
return true;
} // end func isValidDate
I just remove regexp and months checks and use the native php function checkdate. I kept the year
check, checkdate works with years between 1 and 32767, a little wide for an 4 digits year ;).
any comment ? (->commit)
pa