<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
$date1=strtotime('2011-07-20'); //把日期转换成时间戳
$date2=time(); //取当前时间的时间戳
$nowtime=strftime("%y年-%m月-%d日",$date2); //格式化输出日期
$days=round(($date1-$date2)/3600/24); //四舍五入
echo '<font color="red">'.$days.'</font>天';
echo '<br/>距交博会';
echo '<br/><font color="red">2011年7月20日</font>';
?>
转载于:https://my.oschina.net/wangwang110/blog/10465