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);
/////
<?PHP文章来源:http://it503.com/detail.PHP
$Date_1=双引号2003-7-15双引号;//也可以是:$Date_1=双引号2003-7-1523:29:14双引号;
$Date_2=双引号1982-10-1双引号;
$d1=strtotime($Date_1);
$d2=strtotime($Date_2);
$Days=round(($d1-$d2)/3600/24);
Echo双引号偶已经奋斗了$Days天^_^双引号;
?>
添加收藏到:
关键词:PHP时间加减,php
