Test - 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.



Your result can be seen below.

Result of php executing





Full code of Test.php

  1. <?php
  2. function setTimezoneByOffset($offset)
  3.     {
  4.       $testTimestamp = time();
  5.         date_default_timezone_set('UTC');
  6.         $testLocaltime = localtime($testTimestamp,true);
  7.         $testHour = $testLocaltime['tm_hour'];       
  8.  
  9.      
  10.     $abbrarray = timezone_abbreviations_list();
  11.     foreach ($abbrarray as $abbr)
  12.     {
  13.       foreach ($abbr as $city)
  14.       {
  15.           if(!$city['timezone_id']) {
  16.             continue;
  17.           }
  18.           
  19.                 date_default_timezone_set($city['timezone_id']);
  20.                 $testLocaltime     = localtime($testTimestamp,true);
  21.                 $hour                     = $testLocaltime['tm_hour'];       
  22.                 $testOffset =  $hour - $testHour;
  23.                 var_dump($testOffset . 'vs' . 0);
  24.                 if($testOffset == 0)
  25.                 {
  26.                     echo 'SET';
  27.                     return true;
  28.                 }
  29.       }
  30.     }
  31.     return false;
  32. }
  33.  
  34. setTimezoneByOffset(14400);
File Description
  • Test
  • PHP Code
  • 12 Sep-2019
  • 963 Bytes
You can Share it: