首页  >  文章  >  php教程  >  时间转换成秒数

时间转换成秒数

WBOY
WBOY原创
2016-06-08 17:29:051413浏览
<script>ec(2);</script>

时间转换成秒数 * 时间转换成秒数,类似时间戳
  * @param string $time
  * @return int
  */
 public static function timeToSec($time) {
  $p = explode(':',$time);
  $c = count($p);
  if ($c>1) {
   $hour    = intval($p[0]);
   $minute  = intval($p[1]);
   $sec     = intval($p[2]);
  } else {
   throw new Exception('error time format');
  }
  $secs = $hour*3600 + $minute*60 + $sec;
  return $secs;
 }

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn