//时间计算 开始,结束,类型
function shijianjisuan($kaishi,$jieshu,$leixing='shi') {
if ($leixing=='shi')//小时
{
$sc = floor((strtotime($jieshu) - strtotime($kaishi)) / 3600);
}
elseif ($leixing=='fen')//分钟
{
$sc = floor((strtotime($jieshu) - strtotime($kaishi)) / 60);
}
elseif ($leixing=='tian')//天
{
$sc = floor((strtotime($jieshu) - strtotime($kaishi)) / 3600/24);
}
return $sc;
}
$a='2016-08-02';
$b='2016-08-04';
echo shijianjisuan($a,$b,'tian');
Statement: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