Created
May 13, 2016 00:57
-
-
Save turtlix/61eb2db53cc8df3f7f0c1df6130dd100 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function age($date){ | |
$time = strtotime($date); | |
if($time === false){ | |
return ''; | |
} | |
$year_diff = ''; | |
$date = date('Y-m-d', $time); | |
list($year,$month,$day) = explode('-',$date); | |
$year_diff = date('Y') - $year; | |
$month_diff = date('m') - $month; | |
$day_diff = date('d') - $day; | |
if ($day_diff < 0 || $month_diff < 0) $year_diff-; | |
return $year_diff; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment