php实现指定日期之间的间隔天数计算方法

php实现指定日期之间的间隔天数计算方法

$date1 = strtotime('2011-04-30'); //把日期转换成时间戳
$date2 = time(); //取当前时间的时间戳

$nowtime=strftime("%y年-%m月-%d日 ",$date2); //格式化输出日期

$days=round(($date1-$date2)/3600/24); //四舍五入

echo "今天是<font color="red">".$nowtime."</font>";
echo "<br/>距".strftime("%y年-%m月-%d日 ",$date1)."www.3ppt.com还有<font colr="red">".$days."</font>天";

echo date("y-m-d h:i:s",strtotime("now")). "<br />";
echo date("y-m-d h:i:s",strtotime("10 september 2000")). "<br />";
echo date("y-m-d h:i:s",strtotime("+2 day")). "<br />";
echo date("y-m-d h:i:s",strtotime("+1 week")). "<br />";
echo date("y-m-d h:i:s",strtotime("+1 week 2 days 4 hours 2 seconds")). "<br />";
echo date("y-m-d h:i:s",strtotime("next thursday")). "<br />";
echo date("y-m-d h:i:s",strtotime("last monday")). "<br />";
echo date("y-m-d h:i:s",strtotime("+3 day",strtotime('2001-01-01')));

posted on 2011-04-28 13:05  志向不在北京  阅读(1731)  评论(0编辑  收藏  举报

导航