Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F36893038
TimeZoneSelector.php
JorisDarlingtonQuarshie
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Authored By
JorisDarlingtonQuarshie
Mar 5 2023, 3:29 PM
2023-03-05 15:29:01 (UTC+0)
Size
825 B
Referenced Files
None
Subscribers
None
TimeZoneSelector.php
View Options
<?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
Details
Attached
Mime Type
text/x-php
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
10760700
Default Alt Text
TimeZoneSelector.php (825 B)
Attached To
Mode
T331225: Add UTC in the WSContest contest page
Attached
Detach File
Event Timeline
Log In to Comment