Finding the number of days between two dates

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

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

30条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 00:24

    number of days between two dates in PHP

          function dateDiff($date1, $date2)  //days find function
            { 
                $diff = strtotime($date2) - strtotime($date1); 
                return abs(round($diff / 86400)); 
            } 
           //start day
           $date1 = "11-10-2018";        
           // end day
           $date2 = "31-10-2018";    
           // call the days find fun store to variable 
           $dateDiff = dateDiff($date1, $date2); 
    
           echo "Difference between two dates: ". $dateDiff . " Days "; 
    

提交回复
热议问题