在我们的网站上,我们有很多游泳时间,我们希望转换为秒.即1:23:33.03或58:22.43.有没有PHP功能可以做到这一点?MySQL功能?
zer*_*kms 11
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_time-to-sec
mysql> SELECT TIME_TO_SEC('22:23:00');
-> 80580
mysql> SELECT TIME_TO_SEC('00:39:38');
-> 2378
Run Code Online (Sandbox Code Playgroud)
function time2seconds($time='00:00:00')
{
list($hours, $mins, $secs) = explode(':', $time);
return ($hours * 3600 ) + ($mins * 60 ) + $secs;
}
Run Code Online (Sandbox Code Playgroud)
从这里开始.
MySQL也有TIME_TO_SEC()