Use PHP to extract birthdays from your ID, including 15-and 18-bit IDs
function Getidcardinfo ($IDCard, $format =1) {$result [' Error ']=0;//0: Unknown error, 1: Identity card format error, 2: Error-free $result [' flag ']= ';//0 marked adult , 1 indicates underage $result [' tdate ']= ';//birthday, format such as: 2012-11-15 if (!preg_match ("/^ (\d{15}$|^\d{18}$|^\d{17} (\d| x|x)) ($/", $IDCard)) {$result [' Error ']=1; return $result; }else{if (strlen ($IDCard) ==18) {$tyear =intval (substr ($IDCard, 6,4)); $tm $tday =intval (substr ($IDCard, 12,2)); } elseif (Strlen ($IDCard) ==15) {$tyear =intval ("n". substr ($IDCard, 6,2)); $tm $tday =intval (substr ($IDCard, 10,2)); if ($tyear >date ("Y") | | $tyear < (date ("Y") -100)) {$flag = 0; } elseif ($tmonth <0| | $tmonth >12) {$flag = 0; } elseif ($tday <0| | $tday >31) {$flag = 0; }else {if ($format) {$tdate = $tyear. " -". $tmonth." -". $tday; } else {$tdate = $tmonth. " -". $tday; if (Time ()-mktime (0,0,0, $tmonth, $tday, $tyear)) (>18*365*24*60*60) {$flag = 0; } else {$flag = 1; }}} $result [' Error ']=2;//0: Unknown error, 1: ID card format error, 2: no error $result [' Isadult ']= $flag;//0 marked adult, 1 marked underage $result [' Birthday ']= $tdate;//Birthday date return $ Result }
The above describes the use of PHP to achieve from the ID card to extract the birthday, including PHP, identity card aspects of the content, I hope that the PHP tutorial interested in a friend helpful.