/* *秒数转换为时分秒 */ function second_ctime($miao,$type=0) { $s=gmdate('H:i:s', $miao); //00:00:30 $time = explode(':', $s); $time['0'] == '00' ? $h = 0 : $h = $time['0']; $time['1'] == '00' ? $m = 0 : $m = $time['1']; $time['2'] == '00' ? $s = 0 : $s = $time['2']; $ftime = (empty($h) ? (empty($m) ? $s .'秒' : (empty($s) ? $m . '分' : $m . '分' . $s .'秒')) :(empty($m) && empty($s) ? $h .'小时' : (empty($m) ? $h . '时' . $s . '秒' : (empty($s) ? $h . '小时' . $m . '分' : $h . '小时' . $m . '分' .$s . '秒')))); if ($type){ $ftime = $h . '时' . $m . '分' .$s . '秒'; } return $ftime; } /* *包含时分秒的字符串,转换为秒数 */ function second_statistics($strs){ $minute=0; if($strs){ $patterns = "/(\d+)时/"; preg_match_all($patterns,$strs,$zzTime); $Time=isset($zzTime[1][0])?$zzTime[1][0]:0; $patterns = "/(\d+)分/"; preg_match_all($patterns,$strs,$zzTimeFen); $TimeFen=isset($zzTimeFen[1][0])?$zzTimeFen[1][0]:0; $patterns = "/(\d+)秒/"; preg_match_all($patterns,$strs,$zzTimeMiao); $TimeMiao=isset($zzTimeMiao[1][0])?$zzTimeMiao[1][0]:0; $minute=$Time*60*60+$TimeFen*60+$TimeMiao; } return $minute; }
秒数转换为时分秒
最新推荐文章于 2022-04-13 17:54:25 发布