当前位置:编程学习 > php >>

时间转换成秒数

时间转换成秒数 * 时间转换成秒数,类似时间戳
  * @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;
 }

补充:Php教程,Php常用代码 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,