calculate next day at 8am - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.

Name: calculate next day at 8am fullscreencopydownloadembedprint


Your result can be seen below.

Result of php executing





Full code of calculate next day at 8am.php

  1. <?php
  2. $timeZone = 3600;
  3. $serverTime = time();
  4. echo 'Current Server time: '.date("Y-m-d H:i:s",$serverTime).PHP_EOL;
  5. $currentDeviceTime = time()+$timeZone;
  6. echo 'Current Device time: '.date("Y-m-d H:i:s",$currentDeviceTime).PHP_EOL;
  7.  
  8. //calculate next day for device time
  9. $nextDay = mktime(8,0,0,date("n", $currentDeviceTime),date("j",$currentDeviceTime)+ 1 ,date("Y", $currentDeviceTime))-$timeZone;
  10. echo 'Next Day Device time: '.$nextDay.PHP_EOL;
  11.  
  12. $diff = strtotime($nextDay)-$currentDeviceTime;
  13. echo 'Defference between nextday and current device time is = '.$diff;
File Description
  • calculate next day at 8am
  • PHP Code
  • 16 Feb-2018
  • 566 Bytes
You can Share it: