Php checks whether it is a valid time format regular. The following summarizes several methods of verifying whether the date entered by the user is correct using php. if you need it, refer to it. The checkdate () function verifies a greaguri date. The example below summarizes several methods of using php to verify whether the date entered by the user is the correct date. For more information, see.
The checkdate () function verifies a greaguri date.
Example
The code is as follows: |
|
Var_dump (checkdate (12, 31, 2000 )); Var_dump (checkdate (2003 )); Var_dump (checkdate (2004 )); ?> Output: Bool (true) Bool (false) Bool (true) |
Regular date
Example 1
/**
The code is as follows: |
|
* Check whether 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
Regular expression verification date
The code is as follows: |
|
$ Reg = "/d {4}-d {2}-d {2 }/"; Preg_match ($ reg, $ days, $ arr ); Print_r ($ arr ); |
Bytes. The checkdate () function verifies a greaguri date. Example...