예제 #1
0
     }
 }
 unset($translStatus);
 //
 $form->setSelectOptFill('language', $ui_language);
 $form->setFieldOptionsState('language', $cfgPtr['language']);
 $form->setBlockHint('hint-lang', _('Select in which language you want the webGUI to be displayed.'));
 //
 $form->exitBlock();
 $form->startBlock('rw_tz');
 $form->setLabel(null, _('Time zone'), 'timezone', 'class=labelcol');
 $form->startBlock('rw_tz', 'right');
 $form->setField('timezone', 'select', 'name=timezone');
 $form->setDefault('timezone', '99000');
 // fill the timezone select field group
 $tzData = getTzData(false);
 foreach (array_keys($tzData) as $grpKey) {
     $arrTz = array();
     $grpName = $tzData[$grpKey]['group'];
     foreach (array_keys($tzData[$grpKey]) as $tzKey) {
         if (is_array($tzData[$grpKey][$tzKey])) {
             $zoneId = $grpKey . $tzKey;
             $zoneName = $tzData[$grpKey][$tzKey][0];
             $arrTz[$zoneId] = $zoneName;
         }
     }
     $form->setSelectOptFill('timezone', $arrTz, $grpName);
 }
 unset($tzData, $arrTz, $grpKey, $grpName, $tzKey, $zoneId, $zoneName);
 //
 $form->setFieldOptionsState('timezone', $cfgPtr['timezone']);
예제 #2
0
<?php

require_once 'config.php';
$sendDate = date('Y-m-d H:i', time() + 3600 * 24);
$offsets = array();
if ($_POST) {
    // local time offset
    $sendDate = $_POST['TZ']['sendDate'];
    $dateTime = strtotime($sendDate);
    $local = getTzData(-33.87358679497551, 151.2067437171936, $dateTime);
    // get the time offset for each code
    foreach ($mc_edm_config['sending_matrix'] as $code => $config) {
        $geo = $config['geo'];
        $response = getTzData($geo['lat'], $geo['lng'], $dateTime);
        if ($response) {
            $add = $local->totalOffset - $response->totalOffset;
            $newTime = $dateTime + $add;
            $offsets[$code] = array(date('Y-m-d H:i', $newTime), $add);
        }
    }
}
function getTzData($lat, $lng, $time = false)
{
    if (!$time) {
        $time = time();
    }
    $url = 'https://maps.googleapis.com/maps/api/timezone/json?location=' . $lat . ',' . $lng . '&timestamp=' . $time . '&sensor=false';
    $c = curl_init($url);
    curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($c);
    $tzResponse = false;