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

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


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.


You can easily get tomorrow at midnight timestamp with:

$tomorrow_timestamp = strtotime('tomorrow');

If you want to be able to do a variable amount of days you could easily do it like so:

$days = 4;$x_num_days_timestamp = strtotime(date('m/d/Y', strtotime("+$days days"))));


$tomorrow = strtotime('+1 day', strtotime(date('Y-m-d')));$secondsLeftToday = time() - $tomorrow;