Finding the number of days between two dates

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

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

30条回答
  •  独厮守ぢ
    2020-11-22 00:14

    Try using Carbon

    $d1 = \Carbon\Carbon::now()->subDays(92);
    $d2 = \Carbon\Carbon::now()->subDays(10);
    $days_btw = $d1->diffInDays($d2);
    

    Also you can use

    \Carbon\Carbon::parse('')
    

    to create an object of Carbon date using given timestamp string.

提交回复
热议问题