Home > Backend Development > PHP Tutorial > PHP Get the middle month between two months

PHP Get the middle month between two months

不言
Release: 2023-03-23 12:56:01
Original
1708 people have browsed it

The content of this article is to share with you PHP to obtain the intermediate month code between two months. Friends in need can refer to it


        $time1 = strtotime('2014-10-04'); //开始日期

        $time2 = strtotime('2015-02-06'); //结束日期

        $month = array(); //定义数组

        $month[] = date('Y-m',$time1);

        while( ($time1 = strtotime(&#39;+1 month&#39;, $time1)) <= $time2){

            $month[] = date(&#39;Y-m&#39;,$time1); // 取得递增月;
        }

        print_r($month);
Copy after login



The above is the detailed content of PHP Get the middle month between two months. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template