当前位置: 首页>>代码示例>>PHP>>正文


PHP get_user_timezone_offset函数代码示例

本文整理汇总了PHP中get_user_timezone_offset函数的典型用法代码示例。如果您正苦于以下问题:PHP get_user_timezone_offset函数的具体用法?PHP get_user_timezone_offset怎么用?PHP get_user_timezone_offset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_user_timezone_offset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_pm_gmt_from_usertime

 /**
  * Test pm_gmt_from_usertime() function
  * @param int $intimestamp the input timestamp
  * @param float|int|string $timezone the timezone of $intimestamp
  * @param int $outtimestamp the GMT timestamp for $intimestamp in $timezone
  * @dataProvider pm_gmt_from_usertime_dataprovider
  */
 public function test_pm_gmt_from_usertime($intimestamp, $timezone, $outtimestamp)
 {
     if (get_user_timezone_offset($timezone) == 99) {
         $this->markTestSkipped("\nSkipping test_pm_gmt_from_usertime() with undefined timezone = '{$timezone}'\n");
     } else {
         $this->assertEquals($outtimestamp, pm_gmt_from_usertime($intimestamp, $timezone));
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:15,代码来源:pm_gmt_from_usertime_test.php

示例2: get_end_time

 function get_end_time()
 {
     if ($this->endtimehour >= 25 || $this->endtimeminute >= 61) {
         return 0;
     }
     $endtime = ($this->endtimehour - get_user_timezone_offset()) * HOURSECS;
     $endtime += $this->endtimeminute * MINSECS;
     return $endtime;
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:9,代码来源:pmclass.class.php

示例3: set_parameters

 /**
  * Sets the parameters property of the extended class
  *
  * Sets the parameters property of the extended file resource class
  *
  * @param    USER  global object
  * @param    CFG   global object
  */
 function set_parameters()
 {
     global $USER, $CFG;
     $site = get_site();
     $this->parameters = array('label2' => array('langstr' => "", 'value' => '/optgroup'), 'label3' => array('langstr' => get_string('course'), 'value' => 'optgroup'), 'courseid' => array('langstr' => 'id', 'value' => $this->course->id), 'coursefullname' => array('langstr' => get_string('fullname'), 'value' => $this->course->fullname), 'courseshortname' => array('langstr' => get_string('shortname'), 'value' => $this->course->shortname), 'courseidnumber' => array('langstr' => get_string('idnumbercourse'), 'value' => $this->course->idnumber), 'coursesummary' => array('langstr' => get_string('summary'), 'value' => $this->course->summary), 'courseformat' => array('langstr' => get_string('format'), 'value' => $this->course->format), 'courseteacher' => array('langstr' => get_string('wordforteacher'), 'value' => $this->course->teacher), 'courseteachers' => array('langstr' => get_string('wordforteachers'), 'value' => $this->course->teachers), 'coursestudent' => array('langstr' => get_string('wordforstudent'), 'value' => $this->course->student), 'coursestudents' => array('langstr' => get_string('wordforstudents'), 'value' => $this->course->students), 'label4' => array('langstr' => "", 'value' => '/optgroup'), 'label5' => array('langstr' => get_string('miscellaneous'), 'value' => 'optgroup'), 'lang' => array('langstr' => get_string('preferredlanguage'), 'value' => current_language()), 'sitename' => array('langstr' => get_string('fullsitename'), 'value' => format_string($site->fullname)), 'serverurl' => array('langstr' => get_string('serverurl', 'resource', $CFG), 'value' => $CFG->wwwroot), 'currenttime' => array('langstr' => get_string('time'), 'value' => time()), 'encryptedcode' => array('langstr' => get_string('encryptedcode'), 'value' => $this->set_encrypted_parameter()), 'label6' => array('langstr' => "", 'value' => '/optgroup'));
     if (!empty($USER->id)) {
         $userparameters = array('label1' => array('langstr' => get_string('user'), 'value' => 'optgroup'), 'userid' => array('langstr' => 'id', 'value' => $USER->id), 'userusername' => array('langstr' => get_string('username'), 'value' => $USER->username), 'useridnumber' => array('langstr' => get_string('idnumber'), 'value' => $USER->idnumber), 'userfirstname' => array('langstr' => get_string('firstname'), 'value' => $USER->firstname), 'userlastname' => array('langstr' => get_string('lastname'), 'value' => $USER->lastname), 'userfullname' => array('langstr' => get_string('fullname'), 'value' => fullname($USER)), 'useremail' => array('langstr' => get_string('email'), 'value' => $USER->email), 'usericq' => array('langstr' => get_string('icqnumber'), 'value' => $USER->icq), 'userphone1' => array('langstr' => get_string('phone') . ' 1', 'value' => $USER->phone1), 'userphone2' => array('langstr' => get_string('phone') . ' 2', 'value' => $USER->phone2), 'userinstitution' => array('langstr' => get_string('institution'), 'value' => $USER->institution), 'userdepartment' => array('langstr' => get_string('department'), 'value' => $USER->department), 'useraddress' => array('langstr' => get_string('address'), 'value' => $USER->address), 'usercity' => array('langstr' => get_string('city'), 'value' => $USER->city), 'usertimezone' => array('langstr' => get_string('timezone'), 'value' => get_user_timezone_offset()), 'userurl' => array('langstr' => get_string('webpage'), 'value' => $USER->url));
         $this->parameters = $userparameters + $this->parameters;
     }
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:18,代码来源:resource.class.php

示例4: test_pm_timestamp

 /**
  * Test pm_gmt_from_usertime() function
  * @param array $intimeparts the input time components array
  * @param float|int|string $timezone the timezone of $intimestamp
  * @param int $outtimestamp the GMT timestamp for $intimestamp in $timezone
  * @dataProvider pm_timestamp_dataprovider
  */
 public function test_pm_timestamp($intimeparts, $timezone, $outtimestamp)
 {
     if ($outtimestamp == 0) {
         $outtimestamp = mktime(2, 3, 4, 1, 1, 2013);
     }
     if (get_user_timezone_offset($timezone) == 99) {
         $this->markTestSkipped("\nSkipping test_pm_gmt_from_usertime() with undefined timezone = '{$timezone}'\n");
     } else {
         if (is_array($outtimestamp)) {
             $outtimestamp = call_user_func_array('mktime', $outtimestamp);
         }
         $this->assertEquals($outtimestamp, pm_timestamp($intimeparts['hour'], $intimeparts['minute'], $intimeparts['second'], $intimeparts['month'], $intimeparts['day'], $intimeparts['year'], $timezone));
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:21,代码来源:pm_timestamp_test.php

示例5: date

 public function date($message)
 {
     $offset = get_user_timezone_offset();
     $time = $offset < 13 ? $message->time() + $offset : $message->time();
     $now = $offset < 13 ? time() + $offset : time();
     $daysago = floor($now / 86400) - floor($time / 86400);
     $yearsago = (int) date('Y', $now) - (int) date('Y', $time);
     if ($daysago == 0) {
         $content = userdate($time, get_string('strftimetime'));
     } else {
         if ($yearsago == 0) {
             $content = userdate($time, get_string('strftimedateshort'));
         } else {
             $content = userdate($time, get_string('strftimedate'));
         }
     }
     return html_writer::tag('span', s($content), array('class' => 'mail_date'));
 }
开发者ID:miguelangelUvirtual,项目名称:uEducon,代码行数:18,代码来源:renderer.php

示例6: set_parameters

 /**
  * Sets the parameters property of the extended class
  *
  * @param    USER  global object
  * @param    CFG   global object
  */
 function set_parameters()
 {
     global $USER, $CFG;
     $site = get_site();
     $littlecfg = new object();
     // to avoid some notices later
     $littlecfg->wwwroot = $CFG->wwwroot;
     $courseparameters = array('label3' => array('langstr' => get_string('course'), 'value' => 'optgroup'), 'courseid' => array('langstr' => 'id', 'value' => $this->course->id), 'coursefullname' => array('langstr' => get_string('fullnamecourse'), 'value' => $this->course->fullname), 'courseshortname' => array('langstr' => get_string('shortnamecourse'), 'value' => $this->course->shortname), 'courseidnumber' => array('langstr' => get_string('idnumbercourse'), 'value' => $this->course->idnumber), 'coursesummary' => array('langstr' => get_string('summary'), 'value' => $this->course->summary), 'courseformat' => array('langstr' => get_string('format'), 'value' => $this->course->format));
     $roles = get_all_roles();
     $coursecontext = get_context_instance(CONTEXT_COURSE, $this->course->id);
     $roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS);
     foreach ($roles as $role) {
         $courseparameters['course' . $role->shortname] = array('langstr' => get_string('yourwordforx', '', $role->name), 'value' => $role->localname);
     }
     $courseparameters['label4'] = array('langstr' => '', 'value' => '/optgroup');
     $miscparameters = array('label5' => array('langstr' => get_string('miscellaneous'), 'value' => 'optgroup'), 'lang' => array('langstr' => get_string('preferredlanguage'), 'value' => current_language()), 'sitename' => array('langstr' => get_string('fullsitename'), 'value' => format_string($site->fullname)), 'serverurl' => array('langstr' => get_string('serverurl', 'resource', $littlecfg), 'value' => $littlecfg->wwwroot), 'currenttime' => array('langstr' => get_string('time'), 'value' => time()), 'encryptedcode' => array('langstr' => get_string('encryptedcode'), 'value' => $this->set_encrypted_parameter()), 'label6' => array('langstr' => "", 'value' => '/optgroup'));
     $userparameters = array();
     if (!empty($USER->id)) {
         $userparameters = array('label1' => array('langstr' => get_string('user'), 'value' => 'optgroup'), 'userid' => array('langstr' => 'id', 'value' => $USER->id), 'userusername' => array('langstr' => get_string('username'), 'value' => $USER->username), 'useridnumber' => array('langstr' => get_string('idnumber'), 'value' => $USER->idnumber), 'userfirstname' => array('langstr' => get_string('firstname'), 'value' => $USER->firstname), 'userlastname' => array('langstr' => get_string('lastname'), 'value' => $USER->lastname), 'userfullname' => array('langstr' => get_string('fullnameuser'), 'value' => fullname($USER)), 'useremail' => array('langstr' => get_string('email'), 'value' => $USER->email), 'usericq' => array('langstr' => get_string('icqnumber'), 'value' => $USER->icq), 'userphone1' => array('langstr' => get_string('phone') . ' 1', 'value' => $USER->phone1), 'userphone2' => array('langstr' => get_string('phone2') . ' 2', 'value' => $USER->phone2), 'userinstitution' => array('langstr' => get_string('institution'), 'value' => $USER->institution), 'userdepartment' => array('langstr' => get_string('department'), 'value' => $USER->department), 'useraddress' => array('langstr' => get_string('address'), 'value' => $USER->address), 'usercity' => array('langstr' => get_string('city'), 'value' => $USER->city), 'usertimezone' => array('langstr' => get_string('timezone'), 'value' => get_user_timezone_offset()), 'userurl' => array('langstr' => get_string('webpage'), 'value' => $USER->url), 'label2' => array('langstr' => "", 'value' => '/optgroup'));
     }
     $this->parameters = array_merge($userparameters, $courseparameters, $miscparameters);
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:28,代码来源:resource.class.php

示例7: intval

}
if (!isset($frm->an_emailexpiredteacher)) {
    $frm->an_emailexpiredteacher = '';
}
if (!isset($frm->an_sorttype)) {
    $frm->an_sorttype = 'ttl';
}
if (isset($CFG->an_cutoff)) {
    $cutoff = intval($CFG->an_cutoff);
    $mins = $cutoff % 60;
    $hrs = ($cutoff - $mins) / 60;
    $frm->an_cutoff_hour = $hrs;
    $frm->an_cutoff_min = $mins;
}
if (!isset($frm->an_cutoff_hour)) {
    $timezone = format_float(get_user_timezone_offset(), 1);
    $frm->an_cutoff_hour = intval($timezone);
    $frm->an_cutoff_min = intval(round($timezone)) != intval($timezone) ? 35 : 5;
}
if (!isset($frm->acceptmethods)) {
    $frm->acceptmethods = get_list_of_payment_methods();
    $CFG->an_acceptmethods = implode(',', $frm->acceptmethods);
}
if (!isset($frm->acceptccs)) {
    $frm->acceptccs = array_keys(get_list_of_creditcards());
    $CFG->an_acceptccs = implode(',', $frm->acceptccs);
}
if (!isset($frm->acceptechecktypes)) {
    $frm->acceptechecktypes = get_list_of_bank_account_types();
    $CFG->an_acceptechecktypes = implode(',', $frm->acceptechecktypes);
}
开发者ID:veritech,项目名称:pare-project,代码行数:31,代码来源:config_form.php

示例8: test_get_user_timezone_offset

 public function test_get_user_timezone_offset()
 {
     // This is a useless function, the timezone offset may be changing!
     $this->assertSame(-5.0, get_user_timezone_offset('America/New_York'));
     $this->assertDebuggingCalled();
     $this->assertSame(-1.0, get_user_timezone_offset(-1));
     $this->assertSame(1.0, get_user_timezone_offset(1));
     $this->assertSame(1.0, get_user_timezone_offset('Europe/Prague'));
     $this->assertSame(8.0, get_user_timezone_offset('Australia/Perth'));
     $this->assertSame(12.0, get_user_timezone_offset('Pacific/Auckland'));
     $this->resetDebugging();
 }
开发者ID:Keneth1212,项目名称:moodle,代码行数:12,代码来源:date_legacy_test.php

示例9: write_date

 /**
  * Write one date somewhere in the worksheet
  * @param integer $row    Zero indexed row
  * @param integer $col    Zero indexed column
  * @param string  $date   The date to write in UNIX timestamp format
  * @param mixed   $format The XF format for the cell
  */
 function write_date($row, $col, $date, $format=null) {
 /// Calculate the internal PEAR format
     $format = $this->MoodleExcelFormat2PearExcelFormat($format);
 /// Convert the date to Excel format
     $timezone = get_user_timezone_offset();
     if ($timezone == 99) {
         // system timezone offset in seconds
         $offset = (int)date('Z');
     } else {
         $offset = (int)($timezone * HOURSECS * 2);
     }
     $value = ((usertime($date) + $offset) / 86400) + 25569;
 /// Add  the date safely to the PEAR Worksheet
     $this->pear_excel_worksheet->writeNumber($row, $col, $value, $format);
 }
开发者ID:nuckey,项目名称:moodle,代码行数:22,代码来源:excellib.class.php

示例10: stats_getdate

function stats_getdate($time, $timezone = 99)
{
    $timezone = get_user_timezone_offset($timezone);
    if (abs($timezone) > 13) {
        // Server time
        return getdate($time);
    }
    // There is no gmgetdate so we use gmdate instead
    $time += intval((double) $timezone * HOURSECS);
    $datestring = strftime('%S_%M_%H_%d_%m_%Y_%w_%j_%A_%B', $time);
    list($getdate['seconds'], $getdate['minutes'], $getdate['hours'], $getdate['mday'], $getdate['mon'], $getdate['year'], $getdate['wday'], $getdate['yday'], $getdate['weekday'], $getdate['month']) = explode('_', $datestring);
    return $getdate;
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:13,代码来源:statslib.php

示例11: facetofaceb_date_parse_from_format

/**
 * returns unix timestamp from a date string depending on the date format
 *
 * @param string $format e.g. "d/m/Y" - see date_parse_from_format for supported formats
 * @param string $date a date to be converted e.g. "12/06/12"
 * @return int unix timestamp (0 if fails to parse)
 */
function facetofaceb_date_parse_from_format($format, $date) {

    global $CFG;
    $tz = isset($CFG->timezone) ? $CFG->timezone : 99;
    $timezone = get_user_timezone_offset($tz);
    $dateArray = array();
    $dateArray = date_parse_from_format($format, $date);
    if (is_array($dateArray) && isset($dateArray['error_count']) &&
            $dateArray['error_count'] == 0) {
        if (abs($timezone) > 13) {
            $time = mktime($dateArray['hour'], $dateArray['minute'], $dateArray['second'], $dateArray['month'], $dateArray['day'], $dateArray['year']);
        } else {
            $time = gmmktime($dateArray['hour'], $dateArray['minute'], $dateArray['second'], $dateArray['month'], $dateArray['day'], $dateArray['year']);
            $time = usertime($time, $timezone);
        }
        return $time;
    } else {
        return 0;
    }
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:27,代码来源:lib.php

示例12: mediaelementjs_get_variable_values

/**
 * Get the parameter values that may be appended to URL
 * @param object $url module instance
 * @param object $cm
 * @param object $course
 * @param object $config module config options
 * @return array of parameter values
 */
function mediaelementjs_get_variable_values($url, $cm, $course, $config)
{
    global $USER, $CFG;
    $site = get_site();
    $values = array('courseid' => $course->id, 'coursefullname' => format_string($course->fullname), 'courseshortname' => $course->shortname, 'courseidnumber' => $course->idnumber, 'coursesummary' => $course->summary, 'courseformat' => $course->format, 'lang' => current_language(), 'sitename' => format_string($site->fullname), 'serverurl' => $CFG->wwwroot, 'currenttime' => time(), 'urlinstance' => $url->id, 'urlcmid' => $cm->id, 'urlname' => format_string($url->name), 'urlidnumber' => $cm->idnumber);
    if (isloggedin()) {
        $values['userid'] = $USER->id;
        $values['userusername'] = $USER->username;
        $values['useridnumber'] = $USER->idnumber;
        $values['userfirstname'] = $USER->firstname;
        $values['userlastname'] = $USER->lastname;
        $values['userfullname'] = fullname($USER);
        $values['useremail'] = $USER->email;
        $values['usericq'] = $USER->icq;
        $values['userphone1'] = $USER->phone1;
        $values['userphone2'] = $USER->phone2;
        $values['userinstitution'] = $USER->institution;
        $values['userdepartment'] = $USER->department;
        $values['useraddress'] = $USER->address;
        $values['usercity'] = $USER->city;
        $values['usertimezone'] = get_user_timezone_offset();
        $values['userurl'] = $USER->url;
    }
    // weak imitation of Single-Sign-On, for backwards compatibility only
    // NOTE: login hack is not included in 2.0 any more, new contrib auth plugin
    //       needs to be createed if somebody needs the old functionality!
    if (!empty($config->secretphrase)) {
        $values['encryptedcode'] = url_get_encrypted_parameter($url, $config);
    }
    //hmm, this is pretty fragile and slow, why do we need it here??
    if ($config->rolesinparams) {
        $roles = get_all_roles();
        $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
        $roles = role_fix_names($roles, $coursecontext, ROLENAME_ALIAS);
        foreach ($roles as $role) {
            $values['course' . $role->shortname] = $role->localname;
        }
    }
    return $values;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:48,代码来源:locallib.php

示例13: usergetmidnight

/**
 * Given a time, return the GMT timestamp of the most recent midnight
 * for the current user.
 *
 * @param int $date Timestamp in GMT
 * @param float $timezone ?
 * @return ?
 */
function usergetmidnight($date, $timezone = 99)
{
    $timezone = get_user_timezone_offset($timezone);
    $userdate = usergetdate($date, $timezone);
    // Time of midnight of this user's day, in GMT
    return make_timestamp($userdate['year'], $userdate['mon'], $userdate['mday'], 0, 0, 0, $timezone);
}
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:15,代码来源:moodlelib.php

示例14: admin_setting_configcheckbox

// show Quizports on MyMoodle page (default=1)
$settings->add(new admin_setting_configcheckbox('hotpot_enablemymoodle', get_string('enablemymoodle', 'mod_hotpot'), get_string('configenablemymoodle', 'mod_hotpot'), 1));
// enable caching of browser content for each quiz (default=1)
$str = get_string('clearcache', 'mod_hotpot');
$url = new moodle_url('/mod/hotpot/tools/clear_cache.php', array('sesskey' => sesskey()));
$link = html_writer::link($url, $str, array('class' => 'small', 'style' => 'white-space: nowrap', 'onclick' => "this.target='_blank'")) . "\n";
$settings->add(new admin_setting_configcheckbox('hotpot_enablecache', get_string('enablecache', 'mod_hotpot'), get_string('configenablecache', 'mod_hotpot') . ' ' . $link, 1));
// restrict cron job to certain hours of the day (default=never)
if (class_exists('core_date') && method_exists('core_date', 'get_user_timezone')) {
    // Moodle >= 2.9
    $timezone = core_date::get_user_timezone(99);
    $datetime = new DateTime('now', new DateTimeZone($timezone));
    $timezone = ($datetime->getOffset() - dst_offset_on(time(), $timezone)) / 3600.0;
} else {
    // Moodle <= 2.8
    $timezone = get_user_timezone_offset();
}
if (abs($timezone) > 13) {
    $timezone = 0;
} else {
    if ($timezone > 0) {
        $timezone = $timezone - 24;
    }
}
$options = array();
for ($i = 0; $i <= 23; $i++) {
    $options[($i - $timezone) % 24] = gmdate('H:i', $i * HOURSECS);
}
$settings->add(new admin_setting_configmultiselect('hotpot_enablecron', get_string('enablecron', 'mod_hotpot'), get_string('configenablecron', 'mod_hotpot'), array(), $options));
// enable embedding of swf media objects inhotpot quizzes (default=1)
$settings->add(new admin_setting_configcheckbox('hotpot_enableswf', get_string('enableswf', 'mod_hotpot'), get_string('configenableswf', 'mod_hotpot'), 1));
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:31,代码来源:settings.php

示例15: get_end_time

 function get_end_time()
 {
     $endtime = ($this->endtimehour - get_user_timezone_offset()) * HOURSECS;
     $endtime += $this->endtimeminute * MINSECS;
     return $endtime;
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:6,代码来源:cmclass.class.php


注:本文中的get_user_timezone_offset函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。