“strtotime('明天') - 时间()”或“strtotime('明天') - strtotime('now')”将不会给出正确的时间,直到即将到来的午夜

I'm trying to do a simple countdown, but it's giving the wrong time:

$time_seconds_view = strtotime('tomorrow') - time(); echo date("H" . " \h\o\u\\s\, " . "i" . " \m\i\
\u\\t\\e\s\, \a\
\d " . "s" . " \s\\e\c\o\
\d\s", $time_seconds_view);

is spitting out 00 hours, 30 minutes, and 00 seconds

even though date_default_timezone_set($this->session->userdata('timezone')); is set to America/Phoenix

it should be spitting out 07 hours, 30 minutes, and 00 seconds

it's as if PHP is not taking account that I've changed the default timezone.

Anything I'm doing wrong? Thanks for your help!

Use DateTime. It's much better for date math.

$tomorrow = new DateTime('tomorrow');
$now = new DateTime();
$diff = $tomorrow->diff($now);
echo $diff->format("%h hours, %i minutes, %s seconds");
// 7 hours, 12 minutes, 53 seconds

See in action