Home > php教程 > PHP源码 > 时间转换成秒数

时间转换成秒数

WBOY
Release: 2016-06-08 17:29:05
Original
1471 people have browsed it
<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;
 }

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template