Created
October 31, 2012 08:44
-
-
Save toshimaru/3985903 to your computer and use it in GitHub Desktop.
check 8-digits-date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * check 8-digits-date is correct | |
| * | |
| * @param string $date | |
| * @return boolean | |
| */ | |
| protected function checkDate($date) | |
| { | |
| $len = strlen($date); | |
| $intdate = intval($date); | |
| if ($len === 8 && $intdate !== 0) { | |
| $d = str_split($date, 2); | |
| $year = $d[0] . $d[1]; | |
| $month = $d[2]; | |
| $day = $d[3]; | |
| if (checkdate($month, $day, $year)) { | |
| return true; | |
| } else { | |
| return false; | |
| } | |
| } else { | |
| return false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment