Converting birthday in format DDMMMYY to date value in PHP
问题 I've got bunch of birthdays which are stored in format DDMMMYY. I need to convert those to date values, so i can store those in database. Is there any easy way of telling strtotime function that date must be in the past? <?php $datestring = '22SEP41'; echo date('Y-m-d',strtotime($datestring)); //outputs 2041-09-22, should be 1941-09-22 ?> 回答1: <?php $datestring = '22SEP41'; $matches = []; preg_match('/([0-9]{2})([A-Z]{3})([0-9]{2})/', $datestring, $matches); $prefix = ($matches[3] <= date('y'