dlebowski Posted February 2, 2010 Share Posted February 2, 2010 I have found a couple of functions that do different formats. I need it for this format. I need to find out how many days difference there is between two dates. Thanks in advance for the help! Ryan Quote Link to comment https://forums.phpfreaks.com/topic/190684-how-to-subtract-yyyy-mm-dd-from-yyyy-mm-dd/ Share on other sites More sharing options...
mikesta707 Posted February 2, 2010 Share Posted February 2, 2010 assuming the dates are always valid, clever use of the strtotime function would work $date1 = "2010-01-01"; $date2 = "2010-01-25"; $time1 = strtotime($date1); $time2 = strtotime($date2); $diff = abs($time2-$time1); //convert seconds to days $diff /= 60 * 60 * 24;//60 secs a min / 60 mins an hour / 24 hours a day echo ceil($diff); output: 24 Quote Link to comment https://forums.phpfreaks.com/topic/190684-how-to-subtract-yyyy-mm-dd-from-yyyy-mm-dd/#findComment-1005634 Share on other sites More sharing options...
dlebowski Posted February 2, 2010 Author Share Posted February 2, 2010 Thank you! I think that will work! Quote Link to comment https://forums.phpfreaks.com/topic/190684-how-to-subtract-yyyy-mm-dd-from-yyyy-mm-dd/#findComment-1005672 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.