anu123 Posted October 2, 2007 Share Posted October 2, 2007 I have two dates in yy-mm-dd format.i need to find the number of months between these dates Link to comment https://forums.phpfreaks.com/topic/71497-date-difference/ Share on other sites More sharing options...
jaymc Posted October 2, 2007 Share Posted October 2, 2007 use date() to convert your date string into integer months 09 = september 12 = decemeber Then just take them away from each other 12 - 9 = 3 months between us Link to comment https://forums.phpfreaks.com/topic/71497-date-difference/#findComment-359931 Share on other sites More sharing options...
trq Posted October 2, 2007 Share Posted October 2, 2007 <?php $d1 = date('m',strtotime('2007-10-02')); $d2 = date('m',strtotime('2007-07-02')); $d3 = $d1 - $d2; echo $d3; ?> Link to comment https://forums.phpfreaks.com/topic/71497-date-difference/#findComment-359936 Share on other sites More sharing options...
localhost1 Posted October 2, 2007 Share Posted October 2, 2007 another method is that u can use explode function php to separate strings n then compare the corresponding values of the date Link to comment https://forums.phpfreaks.com/topic/71497-date-difference/#findComment-359941 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.