Finding the number of days between two dates

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

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

30条回答
  •  情深已故
    2020-11-22 00:18

    If you want to echo all days between the start and end date, I came up with this :

    $startdatum = $_POST['start']; // starting date
    $einddatum = $_POST['eind']; // end date
    
    $now = strtotime($startdatum);
    $your_date = strtotime($einddatum);
    $datediff = $your_date - $now;
    $number = floor($datediff/(60*60*24));
    
    for($i=0;$i <= $number; $i++)
    {
        echo date('d-m-Y' ,strtotime("+".$i." day"))."
    "; }

提交回复
热议问题