<?php
$ida = '091122671325';
$idb = '091123671325';
function idtodate($id)
{
$year = date("Y");
$month = date("m");
$day = date("d");
$nc = substr($year, 0, 2);
$ny = substr($year, 2, 2);
$y = substr($id, 0, 2);
$m = substr($id, 2, 2);
$d = substr($id, 4, 2);
if($y.$m.$d <= $ny.$month.$day-1) {
$newc = $nc;
} else {
$newc = $nc-1;
}
$new = $newc.$y;
return array('year' => $new, 'month' => $m, 'day' => $d);
}
echo 'ID: '.$ida.'<br>';
print_r(idtodate($ida));
echo '<br><br>';
echo 'ID: '.$idb.'<br>';
print_r(idtodate($idb));
?>
Output:
1. If the year-month-day is smaller than today (2009-11-23), but bigger than 1999: year => 2009
ID: 091122671325
Array ( [year] => 2009 [month] => 11 [day] => 22 )
2. If the year-month-day is the same as, or bigger than today, but smaller than 2000: year => 1909
ID: 091123671325
Array ( [year] => 1909 [month] => 11 [day] => 23 )