I suggest you check out the help for the date_diff() function and go from there.
I think you already have a method that does that in the PHP language, no need to create it yourself.
From the PHP manual on DateTime object:
$datetime1 = date_create('2009-10-11');
$datetime2 = date_create('2009-10-13');
$interval = date_diff($datetime1, $datetime2);
echo $interval->format('%R%d days');
You should only have to change the "%R%d" to whatever you want it to display (example minutes).