php 获取两个时间戳相差的月份

来源:互联网 发布:单台mysql最大tps 编辑:程序博客网 时间:2024/05/19 03:21
function get_month_diff($start, $end = FALSE)
{
$end OR $end = time();
$start = new DateTime("@$start");
$end   = new DateTime("@$end");
$diff  = $start->diff($end);
return $diff->format('%y') * 12 + $diff->format('%m');
}
 
    echo get_month_diff(strtotime("2017-04-1 6:30:01"), strtotime("2017-08-1 6:30:02")) . "\n";
阅读全文
0 0