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


PHP core_date::get_server_timezone_object方法代码示例

本文整理汇总了PHP中core_date::get_server_timezone_object方法的典型用法代码示例。如果您正苦于以下问题:PHP core_date::get_server_timezone_object方法的具体用法?PHP core_date::get_server_timezone_object怎么用?PHP core_date::get_server_timezone_object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core_date的用法示例。


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

示例1: time_to_date_string

 /**
  * Format a timestamp to send to WebEx. Converts to GMT time.
  *
  * @param int       $time Timestamp to format.
  * @return string   The XML.
  */
 public static function time_to_date_string($time)
 {
     // Convert the time to GMT.
     $dt = new \DateTime(date("o:m:d H:i:s", $time), \core_date::get_server_timezone_object());
     $gmttime = $time - $dt->getOffset();
     return date('m/d/Y H:i:s', $gmttime);
 }
开发者ID:programming2web,项目名称:moodle-mod_webexactivity,代码行数:13,代码来源:xml_gen.php

示例2: test_statslib_temp_table_fill

 /**
  * Test the temporary table creation and deletion.
  *
  * @depends test_statslib_temp_table_create_and_drop
  */
 public function test_statslib_temp_table_fill()
 {
     global $CFG, $DB, $USER;
     $dataset = $this->load_xml_data_file(__DIR__ . "/fixtures/statslib-test09.xml");
     $this->prepare_db($dataset[0], array('log'));
     // This nonsense needs to be rewritten.
     $date = new DateTime('now', core_date::get_server_timezone_object());
     $start = self::DAY - $date->getOffset();
     $end = $start + 24 * 3600;
     stats_temp_table_create();
     stats_temp_table_fill($start, $end);
     $this->assertEquals(1, $DB->count_records('temp_log1'));
     $this->assertEquals(1, $DB->count_records('temp_log2'));
     stats_temp_table_drop();
     // New log stores.
     $this->preventResetByRollback();
     stats_temp_table_create();
     $course = $this->getDataGenerator()->create_course();
     $context = context_course::instance($course->id);
     $fcontext = context_course::instance(SITEID);
     $user = $this->getDataGenerator()->create_user();
     $this->setUser($user);
     $this->assertFileExists("{$CFG->dirroot}/{$CFG->admin}/tool/log/store/standard/version.php");
     set_config('enabled_stores', 'logstore_standard', 'tool_log');
     set_config('buffersize', 0, 'logstore_standard');
     set_config('logguests', 1, 'logstore_standard');
     get_log_manager(true);
     $DB->delete_records('logstore_standard_log');
     \core_tests\event\create_executed::create(array('context' => $fcontext, 'courseid' => SITEID))->trigger();
     \core_tests\event\read_executed::create(array('context' => $context, 'courseid' => $course->id))->trigger();
     \core_tests\event\update_executed::create(array('context' => context_system::instance()))->trigger();
     \core_tests\event\delete_executed::create(array('context' => context_system::instance()))->trigger();
     \core\event\user_loggedin::create(array('userid' => $USER->id, 'objectid' => $USER->id, 'other' => array('username' => $USER->username)))->trigger();
     $DB->set_field('logstore_standard_log', 'timecreated', 10);
     $this->assertEquals(5, $DB->count_records('logstore_standard_log'));
     \core_tests\event\delete_executed::create(array('context' => context_system::instance()))->trigger();
     \core_tests\event\delete_executed::create(array('context' => context_system::instance()))->trigger();
     // Fake the origin of events.
     $DB->set_field('logstore_standard_log', 'origin', 'web', array());
     $this->assertEquals(7, $DB->count_records('logstore_standard_log'));
     stats_temp_table_fill(9, 11);
     $logs1 = $DB->get_records('temp_log1');
     $logs2 = $DB->get_records('temp_log2');
     $this->assertCount(5, $logs1);
     $this->assertCount(5, $logs2);
     // The order of records in the temp tables is not guaranteed...
     $viewcount = 0;
     $updatecount = 0;
     $logincount = 0;
     foreach ($logs1 as $log) {
         if ($log->course == $course->id) {
             $this->assertEquals('view', $log->action);
             $viewcount++;
         } else {
             $this->assertTrue(in_array($log->action, array('update', 'login')));
             if ($log->action === 'update') {
                 $updatecount++;
             } else {
                 $logincount++;
             }
             $this->assertEquals(SITEID, $log->course);
         }
         $this->assertEquals($user->id, $log->userid);
     }
     $this->assertEquals(1, $viewcount);
     $this->assertEquals(3, $updatecount);
     $this->assertEquals(1, $logincount);
     set_config('enabled_stores', '', 'tool_log');
     get_log_manager(true);
     stats_temp_table_drop();
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:76,代码来源:statslib_test.php

示例3: test_get_server_timezone_object

 public function test_get_server_timezone_object()
 {
     $this->resetAfterTest();
     $zones = core_date::get_list_of_timezones();
     foreach ($zones as $zone) {
         $this->setTimezone($zone, 'Pacific/Auckland');
         $tz = core_date::get_server_timezone_object();
         $this->assertInstanceOf('DateTimeZone', $tz);
         $this->assertSame($zone, $tz->getName());
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:11,代码来源:date_test.php

示例4: calculate_next_automated_backup

 /**
  * Works out the next time the automated backup should be run.
  *
  * @param mixed $ignoredtimezone all settings are in server timezone!
  * @param int $now timestamp, should not be in the past, most likely time()
  * @return int timestamp of the next execution at server time
  */
 public static function calculate_next_automated_backup($ignoredtimezone, $now)
 {
     $config = get_config('backup');
     $backuptime = new DateTime('@' . $now);
     $backuptime->setTimezone(core_date::get_server_timezone_object());
     $backuptime->setTime($config->backup_auto_hour, $config->backup_auto_minute);
     while ($backuptime->getTimestamp() < $now) {
         $backuptime->add(new DateInterval('P1D'));
     }
     // Get number of days from backup date to execute backups.
     $automateddays = substr($config->backup_auto_weekdays, $backuptime->format('w')) . $config->backup_auto_weekdays;
     $daysfromnow = strpos($automateddays, "1");
     // Error, there are no days to schedule the backup for.
     if ($daysfromnow === false) {
         return 0;
     }
     if ($daysfromnow > 0) {
         $backuptime->add(new DateInterval('P' . $daysfromnow . 'D'));
     }
     return $backuptime->getTimestamp();
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:28,代码来源:backup_cron_helper.class.php


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