[PHP] How to validate this date: 2002-02-31

2002-03-05 Thread Andy

Hi there,

I am still lacking of one error the user can provide:

Desired format: mmdd

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: -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);
}





-- 
PHP General Mailing List (http://wwwphpnet/)
To unsubscribe, visit: http://wwwphpnet/unsubphp




Re: [PHP] How to validate this date: 2002-02-31

2002-03-05 Thread Jason Wong

On Tuesday 05 March 2002 17:27, Andy wrote:
 Hi there,

 I am still lacking of one error the user can provide:

 Desired format: .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?

Try checkdate()


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
If any man wishes to be humbled and mortified, let him become president
of Harvard.
-- Edward Holyoke
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How to validate this date: 2002-02-31

2002-03-05 Thread Andrey Hristov

First but may be not probably the best decision is to use (gm)strftime() and 
(gm)mktime().
So parse your string put the data into mktime() with hour/minute/second for exmaple 
12,0,0 . Strftime() will return a unix
timestamp.
Use that timestamp with strftime() to get the year,month and date. If they are the 
same as the parsed the date is valid, otherwise
not.

Best regards,
Andrey Hristov

- Original Message -
From: Andy [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, March 05, 2002 11:27 AM
Subject: [PHP] How to validate this date: 2002-02-31


 Hi there,

 I am still lacking of one error the user can provide:

 Desired format: .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: -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);
 }





 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How to validate this date: 2002-02-31

2002-03-05 Thread Tomek Golembiewski

Dnia wtorek 05 marzec 2002 10:34, Jason Wong napisa:
 On Tuesday 05 March 2002 17:27, Andy wrote:
  Hi there,
 
  I am still lacking of one error the user can provide:
 
  Desired format: .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?

 Try checkdate()

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php