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; Quote Link to comment Share on other sites More sharing options...
KrisNz Posted February 20, 2008 Share Posted February 20, 2008 works for me.... Quote Link to comment 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; ?> 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.