Saturday, February 28, 2009

How to check for a valid date using php

php have given the checkdate() function to validate user inputted dates.
checkdate($month, $day, $year) all parameters must be integer (numbers).


<?php

$month = $input_month; // should be a number
$day = $input_day; // should be a number
$year = $input_year; // should be a number

if(checkdate($month, $day, $year))
{
echo 'Valid';
}
else
{
echo 'Not valid';
}

?>

No comments:

Post a Comment