Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Time Remaining in Current Day

Tags:

php

How can we find out how many time remains to end the current day from current time[date('Y-m-d H:i:s')] in PHP.

like image 862
Aadi Avatar asked May 03 '26 16:05

Aadi


1 Answers

For example with a combination of mktime() and time():

$left = mktime(23,59,59) - time() +1; // +1 adds the one second left to 00:00

Update:

From Simon's suggestion, mktime(24,0,0) works too:

$left = mktime(24,0,0) - time();
like image 178
Felix Kling Avatar answered May 05 '26 06:05

Felix Kling