首页 > php代码 > 计算两日期间的天数

计算两日期间的天数

<?php
$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;


永久链接:http://www.phprm.com/code/8c752fb18ef0b65f1572d42796a3e26e.html

转载随意!带上文章地址吧。

标签:none

发表留言