Jump to content

Help with Subtracting two dates from each other?


proud

Recommended Posts

 

I need help with subtracting two dates from each other and getting the result in days.

 


$current_time= strtotime("now");

$current_date= date('Y-m-d',$current_time);


$query = mysql_query("SELECT * FROM books where isbn='$isbn' and date_due < '$current_date' ") or die(mysql_error()); 


$fetch= mysql_fetch_array($query);

$due_date=$fetch['date_due'];


$diff_date=$current_date-$due_date;

echo"This book has been delayed for ".$diff_date." days";

 

 

Where the value of $current_date is 2010-02-22

 

and the value of  $due_date is 2010-02-20

 

So how can I get the value of $diff_date to be 2 days?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.