Php method to determine the number of different months between two dates. php date_php tutorial

Source: Internet
Author: User
Tags date1
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 ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.