The following summarizes several ways to use PHP to verify that the date entered by the user is the correct date Oh, a friend who needs to refer to the reference.
The Checkdate () function validates a trellis-high-date.
Example
The code is as follows |
Copy Code |
Var_dump (Checkdate (12,31,2000)); Var_dump (Checkdate (2,29,2003)); Var_dump (Checkdate (2,29,2004)); ?> output: BOOL (TRUE) BOOL (FALSE) BOOL (TRUE) |
Regular date
Example 1
/**
The code is as follows |
Copy Code |
* Check if it is a valid time format * * @param string $time * @return void */ function Is_time ($time) { $pattern = '/[d]{4}-[d]{1,2}-[d]{1,2}s[d]{1,2}:[d]{1,2}:[d]{1,2}/'; Return Preg_match ($pattern, $time); } |
Example 2
The regular validation date
The code is as follows |
Copy Code |
$reg = "/d{4}-d{2}-d{2}/"; Preg_match ($reg, $days, $arr); Print_r ($arr); |
http://www.bkjia.com/PHPjc/628963.html www.bkjia.com true http://www.bkjia.com/PHPjc/628963.html techarticle The following summarizes several ways to use PHP to verify that the date entered by the user is the correct date Oh, a friend who needs to refer to the reference. The Checkdate () function validates a trellis-high-date. Example ...