Blogger Information
Blog 38
fans 0
comment 0
visits 30654
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
组装近半年、近一年的按月查询的字符串格式日期
图图的博客
Original
846 people have browsed it

function time_node($num){

//$num代表需要查询的月份,半年就是6,一年就是12

    $mm = date('m',time())+1;

    $yy = date('Y',time());

    $m = 0;

    while ($m < $num){

        $mm = $mm-1;

        if ($mm == 0){

            $yy -= 1;

            $mm = 12;


        }

        $time[] = $yy."-".$mm;

        $m++;

    }

    return $time;

}

例:近半年的字符串格式日期

print_r(time_node(6));

结果:

微信截图_20200713094717.png

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments