Jump to content

[SOLVED] Calculating number of days


dmccabe

Recommended Posts

Mchl was kind enough yesterday to help with a mySQL query to show items from a database that had a date entered that was more than X number of days ago.

 

However I now need to do something similar with PHP instead.  I need to display number of days between the date entered in the database and today.

 

EG

 

Vehicle was entered on to the system on 01/12/08 and this is in the database.  So my value today would be "29 days" as it is 29 days since that date.

 

I have tried this:

 

$date_in = $row['DATE_IN'];
$today = time();
$duration =  ($today - $date_in);
$duration = ($duration/86400);
echo $duration . " days";

 

but it gives nothing like the right answer.

Link to comment
https://forums.phpfreaks.com/topic/138854-solved-calculating-number-of-days/
Share on other sites

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.