Reputation: 9340
date('i:s',600) will display ten minutes: 10:00. Nice and perfect. I don't care about hours.
I need the reverse function that gets 600 from the string '10:00'
?
So, I'm looking for the reverse function for date('i:s',$secs)
.
$secs
could be any correct time of minutes and seconds displayed as a string from '00:00' to '59:59'.
Upvotes: 1
Views: 186
Reputation: 5896
Not sure how efficient strtotime
is but you could do this:
function seconds($time)
{
return (strtotime("00:" . $time) - strtotime("00:00:00"));
}
Upvotes: 1
Reputation: 13816
function reverse($secs) {
list($i, $s) = explode(':', $secs);
return $i*60 + $s;
}
Anything more is overkill.
Upvotes: 4