<?php
$offset = '+7:30';
// Calculate seconds from offset
list($hours, $minutes) = explode(':', $offset);
$seconds = $hours * 60 * 60 + $minutes * 60;
// Get timezone name from seconds
$tz = timezone_name_from_abbr('', $seconds, 1);
// Workaround for bug #44780
if($tz === false) $tz = timezone_name_from_abbr('', $seconds, 0);
// Set timezone
date_default_timezone_set($tz);
echo $tz . ': ' . date('r');
- Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- Notice: date_default_timezone_set(): Timezone ID '' is invalid in /in/BDEtr on line 13
: Tue, 13 Oct 2015 06:29:47 +0200
- Output for 8.0.13
- Notice: date_default_timezone_set(): Timezone ID '' is invalid in /in/BDEtr on line 13
: Tue, 13 Oct 2015 04:29:47 +0000
- Output for 7.3.32 - 7.3.33
- : Tue, 13 Oct 2015 04:29:47 +0000
preferences:
218.52 ms | 401 KiB | 311 Q