note 94753 added to function.date-parse
| From: | eugene at ultimatecms dot co dot za | Date: | Mon, 23 Nov 2009 10:43:27 +0000 |
| Subject: | note 94753 added to function.date-parse | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163181@lists.php.net to get a copy of this message | ||
<?php
$ida = '091122671325';
$idb = '091123671325';
// This function will match the identity number up to the day, but only for a maximum of
99years+364days.
// Will not work when checking persons older than 100years-1day.
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 )
----
Server IP: 69.147.83.197
Probable Submitter: 198.54.202.214
----
Manual Page -- http://www.php.net/manual/en/function.date-parse.php
Edit -- https://master.php.net/note/edit/94753
Del: integrated -- https://master.php.net/note/delete/94753/integrated
Del: useless -- https://master.php.net/note/delete/94753/useless
Del: bad code -- https://master.php.net/note/delete/94753/bad+code
Del: spam -- https://master.php.net/note/delete/94753/spam
Del: non-english -- https://master.php.net/note/delete/94753/non-english
Del: in docs -- https://master.php.net/note/delete/94753/in+docs
Del: other reasons-- https://master.php.net/note/delete/94753
Reject -- https://master.php.net/note/reject/94753
Search -- https://master.php.net/manage/user-notes.php