dolcezza Posted February 20, 2008 Share Posted February 20, 2008 This is returning 0 with the dates 2010-05-05 ($info['date'])and 2010-05-07($info['enddate']). What am I doing wrong? Thanks in advance $date_diff = subtract_dates($info['date'] , $info['enddate']); //function to find difference between two dates function subtract_dates($begin_date, $end_date) { return round(((strtotime($end_date) - strtotime($begin_date)) / 86400)); } echo $date_diff; Link to comment https://forums.phpfreaks.com/topic/92198-subtract-dates-returning-0/ Share on other sites More sharing options...
KrisNz Posted February 20, 2008 Share Posted February 20, 2008 works for me.... Link to comment https://forums.phpfreaks.com/topic/92198-subtract-dates-returning-0/#findComment-472310 Share on other sites More sharing options...
Barand Posted February 20, 2008 Share Posted February 20, 2008 I'd check your inputs. When I run this I get 2, as expected <?php function subtract_dates($begin_date, $end_date) { //function to find difference between two dates return round(((strtotime($end_date) - strtotime($begin_date)) / 86400)); } $info = array ( 'date' => '2010-05-05', 'enddate' => '2010-05-07' ); $date_diff = subtract_dates($info['date'] , $info['enddate']); echo $date_diff; ?> Link to comment https://forums.phpfreaks.com/topic/92198-subtract-dates-returning-0/#findComment-472314 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.