Php method instance code that determines how many months are different between two dates

Source: Internet
Author: User
This article mainly introduces PHP to determine how many months between the two date method, involving the PHP operation date of the relevant skills, the need for friends can refer to the following

This example describes how PHP determines how many months are different between two dates. Share to everyone for your reference. The implementation method is as follows:

/** * @author Injection (injection.mail@gmail.com) * @var date1 date 1* @var date2 date @var Tags month and day separator mark, default to '-' * @return phase The number of months of poor * @example: $date 1 = "2003-08-11"; $date 2 = "2008-11-06"; $monthNum = Getmonthnum ($date 1, $date 2); Echo $monthNum; */f Unction Getmonthnum ($date 1, $date 2, $tags = '-') {$date 1 = explode ($tags, $date 1); $date 2 = Explode ($tags, $date 2); return a BS ($date 1[0]-$date 2[0]) * + ABS ($date 1[1]-$date 2[1]);}

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.