Finding days between 2 unix timestamps in php

前端 未结 8 1183
一整个雨季
一整个雨季 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:19

    I think that a quick workaround for this is to subtract the amount of a days worth of seconds from the end_stamp until you get to the start_tag.

    //1 day = 86400 seconds
    

    I would build an array of the days to use later.

    EDIT (example)

    $difference = 86400;
    $days = array();
    while ( $start_time < $end_time )
    {
        $days[] = date('M j Y', $end_time);
    
        $end_time -= $difference;
    }
    

    This should cover any time frame even if its over a bunch of months.

提交回复
热议问题