- substr: documentation ( source)
- strftime: documentation ( source)
- str_replace: documentation ( source)
- date: documentation ( source)
- strtotime: documentation ( source)
<?php
$startDate = '2014-08-04';
$currentDate = 'now';
$formattedNow = ($currentDate == "now") ? strftime("%Y%m%d", strtotime(date('Y-m-d'))) : strftime("%Y%m%d", strtotime($currentDate));
$formattedBDay = strftime("%Y%m%d", strtotime($startDate));
$diffDates = $formattedNow - $formattedBDay;
$diffDateLength = strlen($diffDates);
$lastFour = substr($diffDates, -4);
$realAge = str_replace($lastFour, "", $diffDates);
//
if ($realAge == "" || $lastFour == false) {
echo "0";
}else {
echo $realAge;
}