Hi,
I have a function that uses the checkdate() function to validate a date entry. However, the checkdate function itself is returning false for valid dates. For example, if I enter todays date as 2002-10-17, it returns false.
Here's the code:
function valid_date($date)
{
global $date;
global $day;
global $month;
global $year;
global $month_and_day;
$todaycheck = gmdate ("Y-m-d", mktime (1,1,1998));
$date_without_dash = str_replace("-", '', $date);
$day = substr ($date_without_dash, -2);
$month = substr ($date_without_dash, -4, -2);
$year = substr ($date_without_dash, 0, 4);
echo "date = $date<br/>";
echo "date_without_dash = $date_without_dash<br/>";
echo "day = $day<br/>";
echo "month = $month<br/>";
echo "year = $year<br/>";
/*
if (!date_correct_format($date))
{
echo "Please enter date in correct format<br/>";
return false;
}
elseif ($date < $todaycheck)
{
echo "Sorry, you cannot enter past dates.<br/>";
return false;
}
*/
if (checkdate($month, $day, $year))
{
echo "Sorry, you have entered an invalid date<br/>";
echo "Possible causes could be:<br/>";
echo "<ul>";
echo "<li> The number of days in the month is invalid";
echo "<li> The date you have entered is invalid due to a leap year";
echo "</ul>";
return false;
}
else
{
return true;
}
return $day;
return $month;
return $year;
return $month_and_day;
}
Can anyone shed some light on this?