...

View Full Version : different date format validations ??



PHPycho
07-15-2008, 10:47 AM
hello forums!!
can anybody give idea on different types of date format validation function like Y-m-d , dmY etc.
example:

function validateDate($input_date, $format){
//necessary processings....
return bool;
}
validateDate('2008-08-135', 'Y-m-d');

Thanks in advance for the valueable suggestions

JohnDubya
07-15-2008, 02:58 PM
Really, all you should need to do is break up the full date into parts (month, day, and year) and then use the checkdate() function that is built into PHP.

FYI, to break up a full date, just use explode() with a delimiter of "-" or whatever is separating your date. explode() will send the date into an array with each value being a portion of your date. For instance:



$full_date = '2008-07-15';

$date_array = explode('-', $full_date);

$year = $date_array[0];
$month = $date_array[1];
$day = $date_array[2];

if (checkdate($month, $day, $year)) {
//continue with script
}


Does that help?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum