How to validate this date: 2002-02-31
| From: | Andy | Date: | Tue, 05 Mar 2002 09:27:02 +0000 |
| Subject: | How to validate this date: 2002-02-31 | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-87246@lists.php.net to get a copy of this message | ||
Hi there,
I am still lacking of one error the user can provide:
Desired format: yyyy.mm.dd
Asuming he enters a date: 2002-02-31 (There is no Feb 31)
Is there a function which check is the date is ok?
Thanx guys,
Andy
PS: I wrote this function which has the whole:
/*
* Validates the format of date
* requested format: yyyy-mm-dd.
* Return false if not valid
*/
function validate_date($date){
return ereg ("([0-9]{4})-([0-1]{1})([0-2]{1})-([0-3]{1})([0-9]{1})",$date);
}