nikko50 Posted May 25, 2012 Share Posted May 25, 2012 Hi all. New to the forums:) Is it possible to calculate the total number of months of I have a start and end date?So far I have the below that just calculates the total days between two dates. Now how can I get the toal months between the dates. For the below dates it should be around 19.5 or 20 or so. $startDate = "2011-04-05"; $endDate = "2012-11-30"; $days = (strtotime($endDate) - strtotime($startDate)) / (60 * 60 * 24); Tracy Quote Link to comment https://forums.phpfreaks.com/topic/263139-calculate-days-to-total-months-possible/ Share on other sites More sharing options...
ManiacDan Posted May 25, 2012 Share Posted May 25, 2012 There are 30 days in most months. Divide by 30. Quote Link to comment https://forums.phpfreaks.com/topic/263139-calculate-days-to-total-months-possible/#findComment-1348651 Share on other sites More sharing options...
mikosiko Posted May 25, 2012 Share Posted May 25, 2012 depending on your PHP version this http://www.php.net/manual/en/datetime.diff.php could be an option too. Quote Link to comment https://forums.phpfreaks.com/topic/263139-calculate-days-to-total-months-possible/#findComment-1348659 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.