<?php
function dateDiff($start_time,$end_time,$tags = '-')
{
    $date1 = explode($tags,$start_time);
    $date2 = explode($tags,$end_time);
    $month = abs( ($date2[0] - $date1[0]) * 12 + $date2[1] - $date1[1] );
    return $month;
}
echo dateDiff( '2019-03','2020-03' );        //12
echo dateDiff( '2019-12','2020-03' );        //3

如若时光萧瑟去丶
111 声望9 粉丝

weakChickenPeng.