本文整理汇总了PHP中get_timezone_record函数的典型用法代码示例。如果您正苦于以下问题:PHP get_timezone_record函数的具体用法?PHP get_timezone_record怎么用?PHP get_timezone_record使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_timezone_record函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_timezone_offset
/**
* Returns an int which represents the systems's timezone difference from GMT in seconds
*
* @package core
* @category time
* @param float|int|string $tz timezone for which offset is required.
* {@link http://docs.moodle.org/dev/Time_API#Timezone}
* @return int|bool if found, false is timezone 99 or error
*/
function get_timezone_offset($tz) {
if ($tz == 99) {
return false;
}
if (is_numeric($tz)) {
return intval($tz * 60*60);
}
if (!$tzrecord = get_timezone_record($tz)) {
return false;
}
return intval($tzrecord->gmtoff * 60);
}
示例2: get_user_timezone_offset
/**
* Returns a float which represents the user's timezone difference from GMT in hours
* Checks various settings and picks the most dominant of those which have a value
*
* @uses $CFG
* @uses $USER
* @param float $tz If this value is provided and not equal to 99, it will be returned as is and no other settings will be checked
* @return int
*/
function get_user_timezone_offset($tz = 99)
{
global $USER, $CFG;
$tz = get_user_timezone($tz);
if (is_float($tz)) {
return $tz;
} else {
$tzrecord = get_timezone_record($tz);
if (empty($tzrecord)) {
return 99.0;
}
return (double) $tzrecord->gmtoff / HOURMINS;
}
}