How do I find the unix timestamp for the start of the next day in php?

前端 未结 6 1138
梦毁少年i
梦毁少年i 2021-01-07 19:01

I have a unix timestamp for the current time. I want to get the unix timestamp for the start of the next day.

$current_timestamp = time();
$allowable_start_d         


        
6条回答
  •  旧巷少年郎
    2021-01-07 19:53

    The most straightforward way to simply "make" that time:

    $tomorrowMidnight = mktime(0, 0, 0, date('n'), date('j') + 1);
    

    Quote:

    I would like to figure out how many seconds are left in this current day, and only add that many seconds in order to get the unix timestamp for the very first minute of the next day.

    Don't do it like that. Avoid relative calculations whenever possible, especially if it's so trivial to "absolutely" get the timestamp without seconds arithmetics.

提交回复
热议问题