Forum Moderators: coopster

Message Too Old, No Replies

different date format validations ?

         

PHPycho

9:48 am on Jul 15, 2008 (gmt 0)

10+ Year Member



hello forums!
can anybody give idea on different types of date format validation function like Y-m-d , dmY etc.
example:
[PHP]function validateDate($input_date, $format){
//necessary processings....
return bool;
}
validateDate('2008-08-135', 'Y-m-d');[/PHP]

Thanks in advance for the valueable suggestions

henry0

11:08 am on Jul 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Review those functions from the manual and test a few
user added comments/functions

DATE [us3.php.net]

DATETIME [us3.php.net]

deMorte

12:15 pm on Jul 15, 2008 (gmt 0)

10+ Year Member



One thing you should note is that format of Month.Day.Year can be very confusing to European users. Normal notation here is Day.Month.Year and I think American users use notation Month/Day/Year to distinguish between these two notations.

[edited by: deMorte at 12:16 pm (utc) on July 15, 2008]

Nutter

12:30 pm on Jul 15, 2008 (gmt 0)

10+ Year Member



Are you just trying to check if it's a valid date? I've done something like if (strtotime($date)) then... If it can parse the date it returns a value, if not it returns either -1 or false depending on the version of PHP.