Go homepage(回首页) Upload pictures (上传图片) Write articles (发文字帖)
The author:(作者)delvpublished in(发表于) 2013/12/29 4:41:52 php时间加减_php资料_编程技术
下列收集日期计算的方法:
某个日期加几天:
$tdate=date("Y-m-d"); $a=date( "Y-m-d", mktime(0,0,0,date("m"),date("d")+3,date("Y"))); $sql="select * from memo where username='$session_user_id'
and compid=$compid and telldate>='$tdate' and telldate<='$a'
order by id desc"; $ret=mysql_query($sql,$conn);
$a就是今天+三天的时间! $b=date( "Y-m-d", mktime(0,0,0,date("m"),date("d")-3,date("Y"))); $b就是今天-三天的时间!
////
某个日期加n天后的日期
$days=abs((strtotime(date("Y-m-d"))-strtotime("xxxx-xx-xx"))/86400);
/////
="2003-7-15";//也可以是:$Date_1="2003-7-15 23:29:14"; $Date_2="1982-10-1"; $d1=strtotime($Date_1); $d2=strtotime($Date_2); $Days=round(($d1-$d2)/3600/24); Echo "偶已经奋斗了 $Days 天^_^";
赞