note 118515 deleted from timezones by cmb
| From: | cmb@php.net | Date: | Wed, 06 Jul 2016 19:15:03 +0000 |
| Subject: | note 118515 deleted from timezones by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-205907@lists.php.net to get a copy of this message | ||
Note Submitter: aayaresko at gmail dot com
----
to know time zones offset in seconds and hours I used this method.
<?php
$time_zones = $timezone_identifiers = \DateTimeZone::listIdentifiers();
foreach ($time_zones as $time_zone) {
$date = new \DateTime('now', new \DateTimeZone($time_zone));
$offset_in_hours = $date->getOffset() / 60 / 60;
if (!is_null($offset) && $offset == $offset_in_hours) {
echo "{$time_zone}: {$date->getOffset()} ($offset_in_hours)<br>";
}
}
?>