function kind_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));
            $o[] = tz_seconds_to_offset($seconds);
        } catch (Exception $e) {
            //die("Exception : " . $e->getMessage() . '<br />');
            //what to do in catch ? , nothing just relax
        }
    }
    $o = array_unique($o);
    asort($o);
    return $o;
}
Exemplo n.º 2
0
<?php

/**
 * Provides the 'Time' view for the corresponding tab in the Post Meta Box.
 *
 *
 * @package    Indieweb_Post_Kinds
 */
$tzlist = kind_get_timezones();
$tz_seconds = get_option('gmt_offset') * 3600;
$offset = tz_seconds_to_offset($tz_seconds);
$start_offset = ifset($time['start_offset']) ?: $offset;
$end_offset = ifset($time['end_offset']) ?: $offset;
?>
 
<div class="inside hidden">
    <p>Time Properties</p>
    <div id="kindmetatab-time">
      <label for="published"><?php 
_e('Published/Start', 'Post kind');
?>
</label><br/> 
      <input type="date" name="time[start_date]" id="start_date" value="<?php 
echo ifset($time['start_date']);
?>
"/>
      <input type="time" name="time[start_time]" id="start_time" step="1" value="<?php 
echo ifset($time['start_time']);
?>
"/>
   <select name="time[start_offset]" id="start_offset">