Can this format 10-7-2010 validated with php?
With this script:
$array = explode('-', $str);
$day = $array[0];
$month = $array[1];
$year = $array[2];
$Valid = checkdate($month, $day, $year);
I have this error:
checkdate() expects parameter 2 to be long
How can I validate such format?
Thanks in advance
try changing to:
$Valid = checkdate((int)$month, (int)$day, (int)$year);edit: I tried your code and it works fine, could it be you have an poorly formatted date somewhere you’re trying to pass in?
edit2: 10-7-2007 is a valid date, but it sounds like you think it should not be? It is a date in the past, so if you are trying to determine if a date is in the future, you could do something like this:
$isValid = ( strtotime("$year-$month-$day") > time() );