$expiredate='2009/03/31';
$cdate='2009/03/03';
$dateDiff = $expiredate - $cdate;
$fullDays = floor($dateDiff/(60*60*24));

the above method i am using to find the difference between two date.but it is not working.can any one tell me how to find the difference using php.

Recommended Answers

All 2 Replies

You have to convert the dates to unixtimestamp using strtotime.

thanks i got it

$expiredate=strtotime("2009-04-03");
$cdate=strtotime("2009-03-31");
$dateDiff = $expiredate - $cdate;
$fullDays = floor($dateDiff/(60*60*24));
echo $fullDays ;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.