Finding the number of days between two dates

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

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

30条回答
  •  名媛妹妹
    2020-11-22 00:03

    If you're using PHP 5.3 >, this is by far the most accurate way of calculating the difference:

    $earlier = new DateTime("2010-07-06");
    $later = new DateTime("2010-07-09");
    
    $diff = $later->diff($earlier)->format("%a");
    

提交回复
热议问题