Browsing articles tagged with

snippets

Generate a dropdown list of timezones in php

Applications often allow users to select their timezones for reporting the proper time properly. Here is a quick function that can be used to generate a dropdown list of timezones that is easy to read and understand. <?php function get_timezones() { $o = array(); $t_zones = timezone_identifiers_list(); foreach($t_zones as $a) { $t = ''; try { //this throws exception for 'US/Pacific-New' $zone = new DateTimeZone($a); $seconds = $zone->getOffset( new DateTime("now" , $zone) ); $hours ...



Connect with us