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


PHP Datetime::getTimezone方法代码示例

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


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

示例1: test_create_new_blank_datetime

 /**
  * @since 4.6.x
  */
 public function test_create_new_blank_datetime()
 {
     //if timezone is empty string then the setUp didn't work correctly.  For the purpose of this test
     //we want a high positive timezone, so let's force that if necessary
     if (get_option('timezone_string') != 'Australia/Sydney') {
         update_option('timezone_string', 'Australia/Sydney');
         EEM_Datetime::reset();
         EEM_Datetime::instance();
     }
     EE_Registry::instance()->load_helper('DTT_Helper');
     //make sure now is in the timezone we want to test with.
     $now = new Datetime('@' . (time() + DAY_IN_SECONDS * 30));
     $now->setTimeZone(new DateTimeZone(EEH_DTT_Helper::get_timezone()));
     $now->setTime('8', '0', '0');
     $now->setTimeZone(new DateTimeZone('America/Toronto'));
     //get the default datetime
     $default_date = EEM_Datetime::instance()->create_new_blank_datetime();
     $default_date = reset($default_date);
     //assert instance
     $this->assertInstanceOf('EE_Datetime', $default_date);
     //set its timezone to match our expected timezone
     $default_date->set_timezone('America/Toronto');
     $actual = $default_date->get_DateTime_object('DTT_EVT_start');
     $this->assertInstanceOf('DateTime', $actual);
     //assert timezones are the same
     $this->assertEquals($now->getTimezone(), $actual->getTimeZone());
     //assert that we have the correct values on the date... we'll do each part separately to verify.
     $this->assertEquals($now->format('Y'), $actual->format('Y'));
     $this->assertEquals($now->format('m'), $actual->format('m'));
     $this->assertEquals($now->format('d'), $actual->format('d'));
     $this->assertEquals($now->format('H'), $actual->format('H'));
     $this->assertEquals($now->format('i'), $actual->format('i'));
 }
开发者ID:DavidSteinbauer,项目名称:event-espresso-core,代码行数:36,代码来源:EEM_Datetime_Test.php

示例2: writeCalendar

 /**
  * @param array $events
  *
  * @return Twig view in ics format
  */
 private function writeCalendar(array $events)
 {
     $date = new \Datetime();
     $tz = $date->getTimezone();
     return $this->container->get('templating')->render('ClarolineAgendaBundle:Tool:exportIcsCalendar.ics.twig', ['tzName' => $tz->getName(), 'events' => $events]);
 }
开发者ID:claroline,项目名称:distribution,代码行数:11,代码来源:AgendaManager.php

示例3: getUserDateTimeZone

 /**
  * This function wraps around the phprojekt setting for the user timezone
  * to return a DateTimeZone object.
  *
  * @return DateTimeZone The timezone of the user.
  */
 public static function getUserDateTimeZone()
 {
     $tz = Phprojekt_Auth_Proxy::getEffectiveUser()->getSetting('timezone', '0');
     $tz = explode('_', $tz);
     $hours = (int) $tz[0];
     if ($hours >= 0) {
         $hours = '+' . $hours;
     }
     $minutes = '00';
     if (array_key_exists(1, $tz)) {
         // We don't need the minus sign
         $minutes = abs($tz[1]);
     }
     $datetime = new Datetime($hours . ':' . $minutes);
     return $datetime->getTimezone();
 }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:22,代码来源:User.php


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