PHP 时间转换
转载请注明来源:https://www.cnblogs.com/hookjc/
{
//如果已经是时间戳,需要直接返回
if(is_numeric($date)) return $date;
if($date=='') return 0;
$a=explode(" ",$date);
$b=explode("-",$a[0]);
$c=explode(":",$a[1]);
if($b[0]<0) $b[0]=1;
if($b[1]=='') $b[1]=0;
if($b[2]=='') $b[2]=1;
if($c[0]=='') $c[0]=0;
if($c[1]=='') $c[1]=0;
if($c[2]=='') $c[2]=0;
$time=mktime($c[0],$c[1],$c[2],$b[1],$b[2],$b[0]);
return $time;
}
function TimetoDay($time)
{
if($time=='') return time();
$d = floor($time/3600/24);
$h = floor(($time%(3600*24))/3600);
$m = floor(($time%(3600*24)%3600)/60);
return $d."天".$h."小时".$m."分钟";
}