當前位置: 首頁>>代碼示例>>PHP>>正文


PHP timezone_abbreviations_list函數代碼示例

本文整理匯總了PHP中timezone_abbreviations_list函數的典型用法代碼示例。如果您正苦於以下問題:PHP timezone_abbreviations_list函數的具體用法?PHP timezone_abbreviations_list怎麽用?PHP timezone_abbreviations_list使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了timezone_abbreviations_list函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: parse_time

function parse_time($d, $reference = null)
{
    global $Now, $Opt;
    if ($reference === null) {
        $reference = $Now;
    }
    if (!isset($Opt["dateFormatTimezoneRemover"]) && function_exists("timezone_abbreviations_list")) {
        $mytz = date_default_timezone_get();
        $x = array();
        foreach (timezone_abbreviations_list() as $tzname => $tzinfo) {
            foreach ($tzinfo as $tz) {
                if ($tz["timezone_id"] == $mytz) {
                    $x[] = preg_quote($tzname);
                }
            }
        }
        if (count($x) == 0) {
            $x[] = preg_quote(date("T", $reference));
        }
        $Opt["dateFormatTimezoneRemover"] = "/(?:\\s|\\A)(?:" . join("|", $x) . ")(?:\\s|\\z)/i";
    }
    if (@$Opt["dateFormatTimezoneRemover"]) {
        $d = preg_replace($Opt["dateFormatTimezoneRemover"], " ", $d);
    }
    $d = preg_replace('/\\butc([-+])/i', 'GMT$1', $d);
    return strtotime($d, $reference);
}
開發者ID:benesch,項目名稱:peteramati,代碼行數:27,代碼來源:helpers.php

示例2: get_timezone_id

 public static function get_timezone_id()
 {
     // if site timezone string exists, return it
     if ($timezone = get_option('timezone_string')) {
         return $timezone;
     }
     // get UTC offset, if it isn't set return UTC
     if (!($utc_offset = 3600 * get_option('gmt_offset', 0))) {
         return 'UTC';
     }
     // attempt to guess the timezone string from the UTC offset
     $timezone = timezone_name_from_abbr('', $utc_offset);
     // last try, guess timezone string manually
     if (FALSE === $timezone) {
         $is_dst = date('I');
         foreach (timezone_abbreviations_list() as $abbr) {
             foreach ($abbr as $city) {
                 if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) {
                     return $city['timezone_id'];
                 }
             }
         }
     }
     return 'UTC';
     // fallback
 }
開發者ID:geminorum,項目名稱:gmember,代碼行數:26,代碼來源:datetimehelper.class.php

示例3: get_local_timezone

 public static function get_local_timezone($reset = FALSE)
 {
     if ($reset) {
         self::$local_timezone = NULL;
     }
     if (!isset(self::$local_timezone)) {
         $tzstring = get_option('timezone_string');
         if (empty($tzstring)) {
             $gmt_offset = get_option('gmt_offset');
             if ($gmt_offset == 0) {
                 $tzstring = 'UTC';
             } else {
                 $gmt_offset *= HOUR_IN_SECONDS;
                 $tzstring = timezone_name_from_abbr('', $gmt_offset);
                 if (false === $tzstring) {
                     $is_dst = date('I');
                     foreach (timezone_abbreviations_list() as $abbr) {
                         foreach ($abbr as $city) {
                             if ($city['dst'] == $is_dst && $city['offset'] == $gmt_offset) {
                                 $tzstring = $city['timezone_id'];
                                 break 2;
                             }
                         }
                     }
                 }
                 if (false === $tzstring) {
                     $tzstring = 'UTC';
                 }
             }
         }
         self::$local_timezone = new DateTimeZone($tzstring);
     }
     return self::$local_timezone;
 }
開發者ID:Ezyva2015,項目名稱:SMSF-Academy-Wordpress,代碼行數:34,代碼來源:ActionScheduler_TimezoneHelper.php

示例4: setTimezoneByOffset

function setTimezoneByOffset($offset)
{
    date_default_timezone_set('UTC');
    $testTimestamp = time();
    $testLocaltime = localtime($testTimestamp, true);
    $testHour = $testLocaltime['tm_hour'];
    $abbrarray = timezone_abbreviations_list();
    foreach ($abbrarray as $abbr) {
        foreach ($abbr as $city) {
            $val = false;
            if ($city['timezone_id'] != 'Factory' && '' . @$city['timezone_id'] > '') {
                if (isset($city['timezone_id'])) {
                    $val = date_default_timezone_set($city['timezone_id']);
                    if ($val) {
                        $testLocaltime = localtime($testTimestamp, true);
                        $hour = $testLocaltime['tm_hour'];
                        $testOffset = $hour - $testHour;
                        if ($testOffset == $offset || $testOffset == $offset + 24) {
                            return true;
                        }
                    }
                }
            }
        }
    }
    date_default_timezone_set('UTC');
    return false;
}
開發者ID:phroun,項目名稱:jeffutils,代碼行數:28,代碼來源:baseutils.php

示例5: determine_timezone_string

 /**
  * Returns the timezone string for a site, even if it's set to a UTC offset
  *
  * Adapted from http://www.php.net/manual/en/function.timezone-name-from-abbr.php#89155
  *
  * @return string valid PHP timezone string
  */
 private function determine_timezone_string()
 {
     // If site timezone string exists, return it.
     if ($timezone = get_option('timezone_string')) {
         return $timezone;
     }
     // Get UTC offset, if it isn't set then return UTC.
     if (0 === ($utc_offset = get_option('gmt_offset', 0))) {
         return 'UTC';
     }
     // Adjust UTC offset from hours to seconds.
     $utc_offset *= HOUR_IN_SECONDS;
     // Attempt to guess the timezone string from the UTC offset.
     $timezone = timezone_name_from_abbr('', $utc_offset);
     // Last try, guess timezone string manually.
     if (false === $timezone) {
         $is_dst = date('I');
         foreach (timezone_abbreviations_list() as $abbr) {
             foreach ($abbr as $city) {
                 if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) {
                     return $city['timezone_id'];
                 }
             }
         }
     }
     // Fallback to UTC.
     return 'UTC';
 }
開發者ID:Didox,項目名稱:beminfinito,代碼行數:35,代碼來源:class-sitemap-timezone.php

示例6: wp_get_timezone_string

 /**
  * Returns the timezone string for a site, even if it's set to a UTC offset
  *
  * Adapted from http://www.php.net/manual/en/function.timezone-name-from-abbr.php#89155
  *
  * @return string valid PHP timezone string
  */
 private static function wp_get_timezone_string()
 {
     $blog_timezone = get_option('timezone_string');
     $blog_gmt_offset = get_option('gmt_offset', 0);
     // if site timezone string exists, return it
     if ($timezone = $blog_timezone) {
         return $timezone;
     }
     // get UTC offset, if it isn't set then return UTC
     if (0 === ($utc_offset = $blog_gmt_offset)) {
         return 'UTC';
     }
     // adjust UTC offset from hours to seconds
     $utc_offset *= 3600;
     // attempt to guess the timezone string from the UTC offset
     if ($timezone = timezone_name_from_abbr('', $utc_offset, 0)) {
         return $timezone;
     }
     // last try, guess timezone string manually
     $is_dst = date('I');
     foreach (timezone_abbreviations_list() as $abbr) {
         foreach ($abbr as $city) {
             if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) {
                 return $city['timezone_id'];
             }
         }
     }
     // fallback to UTC
     return 'UTC';
 }
開發者ID:baerdaniel,項目名稱:MAT-wordpress,代碼行數:37,代碼來源:DateUtilities.php

示例7: validTimezone

 public function validTimezone($timezone)
 {
     $validTimezones = array();
     $availableTimezones = timezone_abbreviations_list();
     foreach ($availableTimezones as $zone) {
         foreach ($zone as $item) {
             $validTimezones[$item['timezone_id']] = true;
         }
     }
     unset($validTimezones['']);
     return isset($validTimezones[$timezone]);
 }
開發者ID:freezbi,項目名稱:freezbi-php-sdk,代碼行數:12,代碼來源:ExecutionTime.php

示例8: getTimezoneByOffset

 function getTimezoneByOffset($offset)
 {
     $offset *= 3600;
     // convert hour offset to seconds
     $abbrarray = timezone_abbreviations_list();
     foreach ($abbrarray as $abbr) {
         foreach ($abbr as $city) {
             if ($city['offset'] == $offset) {
                 return $city['timezone_id'];
             }
         }
     }
     return false;
 }
開發者ID:m-godefroid76,項目名稱:devrestofactory,代碼行數:14,代碼來源:init.php

示例9: get_timezones

/**
 * Returns possible timezones as:
 * array(
 * 	'<timezone name>' => <true for DST, false otherwise>,
 * 	...
 * )
 *
 * @return array
 */
function get_timezones()
{
    $timezones = array();
    foreach (timezone_abbreviations_list() as $tz_abbreviation) {
        foreach ($tz_abbreviation as $timezone) {
            if (strlen($timezone['timezone_id']) === 0) {
                continue;
            }
            $timezones[$timezone['timezone_id']] = $timezone['dst'];
        }
    }
    ksort($timezones);
    return $timezones;
}
開發者ID:vitalyzhakov,項目名稱:php-api-library,代碼行數:23,代碼來源:user_form.php

示例10: tzOffsetToName

 /**
  * Timezone name
  * 
  * @param  sting  $offset
  * 
  * @return timezone name
  */
 public static function tzOffsetToName($offset)
 {
     $offset *= 3600;
     // convert hour offset to seconds
     $abbrarray = timezone_abbreviations_list();
     foreach ($abbrarray as $abbr) {
         foreach ($abbr as $city) {
             if ($city['offset'] == $offset) {
                 return $city['timezone_id'];
             }
         }
     }
     return FALSE;
 }
開發者ID:rthakur,項目名稱:yephp,代碼行數:21,代碼來源:Helpers.php

示例11: _timezone_convert_to_string_from_offset

 /**
  * all this method does is take an incoming GMT offset value ( e.g. "+1" or "-4" ) and returns a corresponding valid DateTimeZone() timezone_string.
  * @param  string $offset GMT offset
  * @return string         timezone_string (valid for DateTimeZone)
  */
 private static function _timezone_convert_to_string_from_offset($offset)
 {
     //shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did NOT work as expected - its not reliable
     $offset *= 3600;
     // convert hour offset to seconds
     $abbrarray = timezone_abbreviations_list();
     foreach ($abbrarray as $abbr) {
         foreach ($abbr as $city) {
             if ($city['offset'] === $offset && $city['dst'] === FALSE) {
                 return $city['timezone_id'];
             }
         }
     }
     return FALSE;
 }
開發者ID:robert-osborne,項目名稱:event-espresso-core-1,代碼行數:20,代碼來源:EEH_DTT_Helper.helper.php

示例12: set_tz_by_offset

 public function set_tz_by_offset($offset)
 {
     $offset = $offset * 60 * 60;
     $abbrarray = timezone_abbreviations_list();
     foreach ($abbrarray as $abbr) {
         foreach ($abbr as $city) {
             if ($city['offset'] == $offset) {
                 // remember to multiply $offset by -1 if you're getting it from js
                 date_default_timezone_set($city['timezone_id']);
                 return true;
             }
         }
     }
     date_default_timezone_set("ust");
     return false;
 }
開發者ID:iateadonut,項目名稱:signup,代碼行數:16,代碼來源:SignupController.php

示例13: set_time_zone

function set_time_zone($time_zone)
{
    if (preg_match('/(\\+|-)([0-9]{2}):([0-9]{2})/', $time_zone, $matches)) {
        list(, $sign, $hours, $minutes) = $matches;
        $offset = ($sign == '+' ? 1 : -1) * ((int) $hours * 3600 + (int) $minutes * 60);
        if (($time_zone = timezone_name_from_abbr('', $offset, 0)) === FALSE) {
            foreach (timezone_abbreviations_list() as $abbr) {
                foreach ($abbr as $zone) {
                    if (!$zone['dst'] && $zone['offset'] == $offset) {
                        return date_default_timezone_set($zone['timezone_id']);
                    }
                }
            }
        }
    }
    return $time_zone ? date_default_timezone_set($time_zone) : FALSE;
}
開發者ID:nsystem1,項目名稱:neofrag-cms,代碼行數:17,代碼來源:time.php

示例14: TSfromLocalTS

function TSfromLocalTS($ts)
{
    $ts = (int) $ts;
    $uid = (int) sUserMgr()->getCurrentUserID();
    $user = new User($uid);
    $user_timezone = $user->properties->getValue('TIMEZONE');
    $tz = null;
    $offset = null;
    $timezoneAbbreviations = timezone_abbreviations_list();
    foreach ($timezoneAbbreviations as $timezoneAbbreviations_item) {
        foreach ($timezoneAbbreviations_item as $timezone_item) {
            if ($timezone_item['timezone_id'] == $user_timezone) {
                $tz = $timezone_item;
                $offset = $timezone_item['offset'];
            }
        }
    }
    //Windows special fallback
    if (!$tz) {
        switch ($user_timezone) {
            case 'Etc/GMT-11':
                $offset = -39600;
                break;
            case 'Etc/GMT-2':
                $offset = -7200;
                break;
            case 'Atlantic/South_Georgia':
                $offset = -7200;
                break;
            case 'GMT':
                $offset = 0;
                break;
            case 'Etc/GMT+12':
                $offset = 43200;
                break;
        }
    }
    // Save original timezone
    $currentTimeZone = date_default_timezone_get();
    // Get offset of user timezone
    date_default_timezone_set($user_timezone);
    $realOffset = date('Z', $ts);
    // Reset original timezone
    date_default_timezone_set($currentTimeZone);
    return $ts - $realOffset;
}
開發者ID:nrueckmann,項目名稱:yeager,代碼行數:46,代碼來源:common.php

示例15: getTz_array

 public static function getTz_array()
 {
     $tz_array = array();
     foreach (timezone_abbreviations_list() as $abbr => $array) {
         foreach ($array as $id => $array2) {
             $offset = $array2['offset'];
             $timezone_id = $array2['timezone_id'];
             //$tz_byTimeZone[$timezone_id]	= format_time($offset);
             //$tz_byOffset[format_time($offset)]	= $timezone_id;
             $tz_array[$timezone_id] = array('timezone_id' => $timezone_id, 'offset' => TimezoneController::format_time($offset), 'int_offset' => round($offset / 60, 0));
         }
         //exit;
     }
     usort($tz_array, function ($a, $b) {
         return $a['offset'] - $b['offset'];
     });
     return $tz_array;
 }
開發者ID:iateadonut,項目名稱:signup,代碼行數:18,代碼來源:TimezoneController.php


注:本文中的timezone_abbreviations_list函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。