andz Posted February 28, 2009 Share Posted February 28, 2009 Is there any way to display dates in results after subtracting them? echo strtotime($values['bookStart']); echo '<br /><br />'; echo strtotime($values['bookEnd']); echo '<br /><br />'; $res = strtotime($values['bookEnd']) - strtotime($values['bookStart']); date format YYYY-MM-DD $bookStart = '2009-01-02'; $bookEnd = '2009-01-10'; the result should return 8 days Link to comment https://forums.phpfreaks.com/topic/147349-solved-howto-subtract-dates-and-display-result-in-days/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 28, 2009 Share Posted February 28, 2009 If these are in a mysql database, just use the mysql datediff() function in your SELECT query - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_datediff Link to comment https://forums.phpfreaks.com/topic/147349-solved-howto-subtract-dates-and-display-result-in-days/#findComment-773431 Share on other sites More sharing options...
ratcateme Posted February 28, 2009 Share Posted February 28, 2009 echo "time taken: " . round($res/(24*60*60)); should do it Scott. Link to comment https://forums.phpfreaks.com/topic/147349-solved-howto-subtract-dates-and-display-result-in-days/#findComment-773432 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.