Home >php教程 >PHP源码 >计算两日期间的天数

计算两日期间的天数

WBOY
WBOYOriginal
2016-06-08 17:28:181172browse
<script>ec(2);</script>

$now_time = time(); //当前时间
$for_time = mktime(0,0,0,2,24,2010);//设置一个日期
$n_time = $now_time-$for_time;
if( $n_time > 2592000 )

 $echo = round($n_time/2592000).'月前';
}
elseif( $n_time > 6048000 )
{
 $echo = round($n_time/604800).'周前';
}
elseif( $n_time > 86400 )
{
 $echo = round($n_time/86400).'天前';
}
elseif( $n_time > 3600 )
{
 $echo = round($n_time/3600).'小时前';
}
elseif( $n_time > 60 )
{
 $echo = round($n_time/60).'分钟前';
}
else
{
 $echo = $n_time.'秒前';
}
echo $echo;

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