dmccabe Posted December 30, 2008 Share Posted December 30, 2008 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. Quote Link to comment Share on other sites More sharing options...
dmccabe Posted December 30, 2008 Author Share Posted December 30, 2008 Got it by doing the following: $date_in = strtotime($row['DATE_IN']); $today = time(); $duration = $today - $date_in; $duration = round($duration/86400); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.