- substr: documentation ( source)
- var_dump: documentation ( source)
<?php
$id = '287080904421';
// Extract the "hidden" date part from the ID
$date = substr($id, 1, 6);
// Arbitrary decision
// if year < 70, then assume 21st century
// else assume 20th century
if (substr($date, 0, 1) < 7) {
$date = '20' . $date;
} else {
$date = '19' . $date;
}
$birthday = DateTime::createFromFormat('Ymd', $date);
echo $birthday->format('Y-m-d');
$now = new DateTime();
$diff = $now->diff($birthday);
var_dump($diff);
echo $diff->y;