Ok, a really simple question but I am too thick to figure it out. I want to get the difference between two times. For example, "1:07" (1 minute and 7 seconds) and "3:01" (3 minutes and 1 second). It will only be ever minutes and seconds. I have been trying to make use of this:
function timeDiff($firstTime,$lastTime)
{
// convert to unix timestamps
$firstTime=strtotime($firstTime);
$lastTime=strtotime($lastTime);
// perform subtraction to get the difference (in seconds) between times
$timeDiff=$lastTime-$firstTime;
// return the difference
return $timeDiff;
}
But I think I am running in the wrong direction?
Thank you for any help.
EDIT
I tried this: echo timeDiff('1:07','2:30');
I got this output "4980"
What is the above? Is it seconds? I have no idea how to get it as "1:23" which is the difference.
EDIT 2
Thank you all, I learnt so much just from this one thread, esp. Paul's. It works very well and I like the defensiveness!