Installer wrote:According to that, I'm 2006 years old. Not far off. 🙂
How on earth are you getting 2006? You did see the date format should be ISO standard YYYY-MM-DD right? I've noticed a typo in line 2 though - date( 'n' ) should be date( 'z' ) to determine whether birth day has passed yet. Still shouldn't have been more than a year out with the typo.
for ($i = 0; $i < 20; $i++) {
$day = mt_rand(1, 28);
$month = mt_rand(1, 12);
$year = mt_rand(1901, 2005);
echo get_age( "$year-$month-$day" ) . "($year-$month-$day), ";
}
function &get_age($birthDate) {
$years2 = date('Y') - date('Y', strtotime($birthDate));
date('z', strtotime($birthDate)) > date('z') and --$years2;
return $years2;
}
and the results:
45(1961-1-6), 51(1955-1-27), 41(1964-5-7), 45(1960-3-13), 17(1988-5-3), 13(1992-6-22), 82(1923-3-6), 21(1984-8-2), 10(1995-9-6), 30(1975-7-11), 51(1954-9-7), 45(1960-2-25), 69(1936-2-27), 84(1921-11-20), 19(1986-8-26), 69(1936-11-20), 8(1997-7-17), 85(1921-1-24), 85(1920-11-11), 27(1978-5-15),