Finding the number of days between two dates

后端 未结 30 2546
心在旅途
心在旅途 2020-11-21 23:47

How to find number of days between two dates using PHP?

30条回答
  •  忘掉有多难
    2020-11-22 00:02

    function get_daydiff($end_date,$today)
    {
        if($today=='')
        {
            $today=date('Y-m-d');
        }
        $str = floor(strtotime($end_date)/(60*60*24)) - floor(strtotime($today)/(60*60*24));
        return $str;
    }
    $d1 = "2018-12-31";
    $d2 = "2018-06-06";
    echo get_daydiff($d1, $d2);
    

提交回复
热议问题