Home > php教程 > PHP源码 > 一个计算剩余时间的php自定义函数

一个计算剩余时间的php自定义函数

PHP中文网
Release: 2016-05-25 17:00:41
Original
1214 people have browsed it

跳至

public function gettime($time_s,$time_n){
$time_s = strtotime($time_s);
$time_n = strtotime($time_n);
$strtime = '';
$time = $time_n-$time_s;
if($time >= 86400){
return $strtime = date('Y-m-d H:i:s',$time_s);
}
if($time >= 3600){
$strtime .= intval($time/3600).'小时';
$time = $time % 3600;
}else{
$strtime .= '';
}
if($time >= 60){
$strtime .= intval($time/60).'分钟';
$time = $time % 60;
}else{
$strtime .= '';
}
if($time > 0){
$strtime .= intval($time).'秒前';
}else{
$strtime = "时间错误";
}
return $strtime;
}
Copy after login

                   

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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template