3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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; }
based on TNmnn
Output for 4.3.0 - 7.2.6
0