/** * 判断两个时间之间相差的月份 * @param $time1 * @param $time2 * @return float|int */ function get_month_interval($time1, $time2) { if ($time1 > $time2) { $t = $time1; $time1 = $time2; $time2 = $t; } $y1 = date('Y', $time1); $y2 = date('Y', $time2); $m1 = date('m', $time1); $m2 = date('m', $time2); $months = ($y2 - $y1) * 12 + ($m2 - $m1); if ($y2 == $y1) { $months++; } return $months; }
如果帮助到你,请赏杯奶茶喝~
- 本文链接: https://www.shx1024.top//index/article/details/article_id/98.shtml
- 版权声明:本博客所有文章除特别声明外,均默认采用 许可协议。