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"));
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top