Page MenuHomePhabricator

TimeZoneSelector.php

Authored By
JorisDarlingtonQuarshie
Mar 5 2023, 3:29 PM
Size
825 B
Referenced Files
None
Subscribers
None

TimeZoneSelector.php

<?php
// get a list of available timezones
$timezones = DateTimeZone::listIdentifiers();
// create a select element to display the timezones
echo '<select name="timezone">';
// loop through the available timezones and add them to the select element
foreach($timezones as $timezone) {
// create a DateTimeZone object for the current timezone
$tz = new DateTimeZone($timezone);
// get the timezone offset from UTC for the current timezone
$offset = $tz->getOffset(new DateTime());
// format the timezone offset as +/-HH:MM
$offset_formatted = sprintf('%+03d:%02d', $offset / 3600, abs($offset) % 3600 / 60);
// create an option element for the current timezone
echo '<option value="' . $timezone . '">' . $timezone . ' (' . $offset_formatted . ')</option>';
}
echo '</select>';
?>

File Metadata

Mime Type
text/x-php
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
10760700
Default Alt Text
TimeZoneSelector.php (825 B)

Event Timeline