PHP date format Legality regular validation code this section PHP regular date tutorial, provides three kinds of validation user input date is not the correct date format Oh, two kinds are verified with regular date, one is to use Checkdate to verify.
PHP Tutorial Date format legality regular validation code
This PHP regular date tutorial provides three ways to verify that the date entered by the user is not the correct date format Oh, two is verified with a regular date, one is verified with checkdate.
*/
$days = Date ("y-m-d");
Method a regular validation date
$reg = "/d{4}-d{2}-d{2}/";
Preg_match ($reg, $days, $arr);
Print_r ($arr);
Method two with Cehckdate verification
$k = Explode ('-', $days);
if (Checkdate ($k [1], $k [2], $k [0]))
{
echo $days, ' date valid ';
}
Else
{
Echo ' is not a valid date ';
}
Method three simple and intuitive regular verification
if (Ereg ("(19|20) [0-9]{2}-(0[1-9]|1[0-2])-(0[1-9]|[ 12][0-9]|3[01]) $ ", $days))
{
Echo $days, ' for effective date ';
}
Else
{
Echo
' Invalid date ';
}
/*
About the Checkdate function
The Checkdate () function validates a trellis-high-date.
If the specified value is valid, the function returns True, otherwise false is returned.
The date is valid in the following cases:
Month is between and includes 1-12
The value of day is within the range of days that a given month should have, and leap years are taken into account.
Year is between and includes 1 to 32767
Verify format is month/day/year
This site original tutorial, reproduced annotated from www.bKjia.c0m/phper/php.html
*/
http://www.bkjia.com/PHPjc/632365.html www.bkjia.com true http://www.bkjia.com/PHPjc/632365.html techarticle PHP date format Legality regular validation code this section PHP regular date tutorial, provides three kinds of validation user input date is not the correct date format Oh, two kinds of is to use regular date verification, ...