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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.