karldesign Posted April 3, 2007 Share Posted April 3, 2007 Hi, I am looking for a reliable method of finding month differences between 2 dates. I want the difference between $start_date and $end_date, but want to print the difference in months, ie: 22 March 2007 - 22 May 2007 = 2 months. 1 April 2007 - 1 March 2007 = 1 Month... I have seen lots of comparison functions but just want a simple script to get me the number. Link to comment https://forums.phpfreaks.com/topic/45418-solved-php-dates/ Share on other sites More sharing options...
Lumio Posted April 3, 2007 Share Posted April 3, 2007 $months = ($end_date-$start_date)/(60*60*24*7*4) Thats how to use, when you got it in seconds. I see you want it different: <?php $start_date = strtotime('2007-03-22'); $end_date = strtotime('2007-04-22'); $months = ($end_date-$start_date)/(60*60*24*7*4); ?> Link to comment https://forums.phpfreaks.com/topic/45418-solved-php-dates/#findComment-220538 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.