Php method for determining the number of different months between two dates: php date. Php method for determining the number of different months between two dates. The php date example in this article describes how php judges the number of different months between two dates. Share it with you for your reference. Php method to determine the number of different months between two dates, php date
This example describes how to use php to determine the number of different months between two dates. 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.
Examples in this article describes how php judges the number of different months between two dates. Share it with you for your reference ....