Display age based on birthday PHP script
I was looking for a way to keep the About section up to date and came across this one from Dzone that works really well:
function birthday ($birthday)
{
list($year,$month,$day) = explode("-",$birthday);
$year_diff = date("Y") - $year;
$month_diff = date("m") - $month;
$day_diff = date("d") - $day;
if ($month_diff < 0) $year_diff--;
elseif (($month_diff==0) && ($day_diff < 0)) $year_diff--;
return $year_diff;
}
You can activate it with:
echo birthday("YYYY-MM-DD");
« Awesome Buskers on Robson St. - Rent – You’ll See (Guitar Tab/Chords) »
Comments
Thank you sir.
Post a comment