This article describes how to use php to determine the number of different months between two dates. it involves related techniques related to the php operation date, for more information about how to use php to determine the number of different months between two dates, see the example in this article. Share it with you for your reference. The specific implementation method is as follows:
/*** @ Author injection (injection.mail@gmail.com) * @ var date1 date 1 * @ var date2 date 2 * @ var tags delimiter between year, month, and day, the default value is '-' * @ return the number of months * @ example: $ date1 = ""; $ date2 = ""; $ monthNum = getMonthNum ($ date1, $ date2); echo $ monthNum; */function getMonthNum ($ date1, $ date2, $ tags = '-') {$ date1 = explode ($ tags, $ date1 ); $ date2 = explode ($ tags, $ date2); return abs ($ date1 [0]-$ date2 [0]) * 12 + abs ($ date1 [1]-$ date2 [1]);}
I hope this article will help you with php programming.