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. Link to comment https://forums.phpfreaks.com/topic/138854-solved-calculating-number-of-days/ 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); Link to comment https://forums.phpfreaks.com/topic/138854-solved-calculating-number-of-days/#findComment-726075 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.