The most convenient method
echo strtotime('23:59:59')-time();
The fastest method
$now = time(); echo 86400-date('H', $now)*3600- date('i', $now)*60-date('s');
fastermethod
echo 86400-(time()+8*3600)%86400;
Attached test data
xubanditdeMacBook-Pro:~ xubandit$ time php -f a.php real 0m31.146s user 0m30.966s sys 0m0.075s xubanditdeMacBook-Pro:~ xubandit$ time php -f b.php real 0m48.574s user 0m48.329s sys 0m0.098s xubanditdeMacBook-Pro:~ xubandit$ time php -f c.php real 0m11.156s user 0m10.786s sys 0m0.098s xubanditdeMacBook-Pro:~ xubandit$ cat a.php <?php for($i=0;$i<10000000;$i++){ strtotime('23:59:59')-time(); } xubanditdeMacBook-Pro:~ xubandit$ cat b.php <?php for($i=0;$i<10000000;$i++){ $now = time(); 86400-date('H', $now)*3600- date('i', $now)*60-date('s'); } xubanditdeMacBook-Pro:~ xubandit$ cat c.php <?php for($i=0;$i<10000000;$i++){ 86400-(time()+8*3600)%86400; }