Finding the number of days between two dates

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

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

30条回答
  •  北海茫月
    2020-11-22 00:12

    Calculate the difference between two dates:

    $date1=date_create("2013-03-15");
    $date2=date_create("2013-12-12");
    
    $diff=date_diff($date1,$date2);
    
    echo $diff->format("%R%a days");
    

    Output: +272 days

    The date_diff() function returns the difference between two DateTime objects.

提交回复
热议问题