Finding days between 2 unix timestamps in php

前端 未结 8 1066
一整个雨季
一整个雨季 2020-12-13 18:57

Hay, i have a database holding events. There are 2 fields \'start\' and \'end\', these contain timestamps. When an admin enters these dates, they only have the ability to se

相关标签:
8条回答
  • 2020-12-13 19:29

    Try this:

    while($date_start <= $date_end) {
        echo date('M d Y', $date_start) . '<br>';
        $date_start = $date_start + 86400;
    }
    

    Hope this helps !

    0 讨论(0)
  • 2020-12-13 19:30
    $daysInBetween = range($startTs, $endTs, 86400);
    $secondDay = date('M d Y', $daysInBetween[1]);
    /*
    $thirdDay = date('M d Y', $daysInBetween[2]);
    ...
    */
    

    Note that the range() function is inclusive.

    0 讨论(0)
提交回复
热议问题