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.
Result of php executing
Full code of Test.php
- <?php
- function setTimezoneByOffset($offset)
- {
- $testTimestamp = time();
- date_default_timezone_set('UTC');
- $testLocaltime = localtime($testTimestamp,true);
- $testHour = $testLocaltime['tm_hour'];
- $abbrarray = timezone_abbreviations_list();
- foreach ($abbrarray as $abbr)
- {
- foreach ($abbr as $city)
- {
- if(!$city['timezone_id']) {
- continue;
- }
- date_default_timezone_set($city['timezone_id']);
- $testLocaltime = localtime($testTimestamp,true);
- $hour = $testLocaltime['tm_hour'];
- $testOffset = $hour - $testHour;
- var_dump($testOffset . 'vs' . 0);
- if($testOffset == 0)
- {
- echo 'SET';
- return true;
- }
- }
- }
- return false;
- }
- setTimezoneByOffset(14400);