Reputation: 5933
$dateDiff = $mtime - $ctime;
$fullDays = floor($dateDiff/(60*60*24));
$fullHours = floor(($dateDiff-($fullDays*60*60*24))/(60*60));
$fullMinutes = floor(($dateDiff-($fullDays*60*60*24)-($fullHours*60*60))/60);
echo "Difference is $fullDays days, $fullHours hours and $fullMinutes minutes.";
I am looking to add the ability to see weeks as well. I know I could just repeat the same process, but is there a library or an easier way?
Upvotes: 0
Views: 1052
Reputation: 9661
In PHP 5.3 and up, there's the DateTime class. See http://php.net/manual/en/class.datetime.php.
Upvotes: 1