function reverse($secs) {
list($i, $s) = explode(':', $secs);
return $i*60 + $s;
}
Anything more is overkill.
Вопрос
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'.
Решение
function reverse($secs) {
list($i, $s) = explode(':', $secs);
return $i*60 + $s;
}
Anything more is overkill.
Другие советы
Not sure how efficient strtotime
is but you could do this:
function seconds($time)
{
return (strtotime("00:" . $time) - strtotime("00:00:00"));
}