开发者

How to calculate difference between the dates in PHP? [duplicate]

开发者 https://www.devze.com 2023-03-10 07:03 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: How to calculate the difference between two dates using PHP?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How to calculate the difference between two dates using PHP?

How to calculate difference between the dates?

Is there a开发者_开发知识库ny default function for to calculate the date differences?..

Thanks

Ravi


date_diff()

example:

$datetime1 = date_create('2009-10-11');
$datetime2 = date_create('2009-10-13');
$interval = date_diff($datetime1, $datetime2);
echo $interval->format('%R%a days');


$date1 = date("Y/m/d");
$comp_date = "2010/12/1";

if($date1 <= $comp_date)//-------- if for date is less than limit

{

}

else if($date1 > $comp_date)//---------ElseIf for date is greator than limit                      

{


}//----End else if($date1 > $comp_date)

}//--------- End Main if

You can try this method too...

0

精彩评论

暂无评论...
验证码 换一张
取 消