- abs: documentation ( source)
- floor: documentation ( source)
- date: documentation ( source)
- strtotime: documentation ( source)
- printf: documentation ( source)
<?php
$date1 = "2016-01-12 10:10:10";
$date2 = "2016-01-13 10:11:10";
//$diff = abs(strtotime($date2) - strtotime($date1));
$diff = abs(date('Y-m-d',strtotime($date2)) - date('Y-m-d',strtotime($date1)));
$years = floor($diff / (365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
$numberDays = $diff/86400; // 86400 seconds in one day
printf("%d years, %d months, %d days\n", $years, $months, $days);
printf("%d numberDays", $numberDays);