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


PHP DateTimeZone::getName方法代码示例

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


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

示例1: __construct

 /**
  * Constructor.
  *
  * @param   string  $date  String in a format accepted by strtotime(), defaults to "now".
  * @param   mixed   $tz    Time zone to be used for the date. Might be a string or a DateTimeZone object.
  */
 public function __construct($date = 'now', $tz = null)
 {
     // Create the base GMT and server time zone objects.
     if (empty(self::$gmt) || empty(self::$stz)) {
         self::$gmt = new \DateTimeZone('GMT');
         self::$stz = new \DateTimeZone(@date_default_timezone_get());
     }
     // If the time zone object is not set, attempt to build it.
     if (!$tz instanceof \DateTimeZone) {
         if ($tz === null) {
             $tz = self::$gmt;
         } elseif (is_string($tz)) {
             $tz = new \DateTimeZone($tz);
         }
     }
     // If the date is numeric assume a unix timestamp and convert it.
     date_default_timezone_set('UTC');
     $date = is_numeric($date) ? date('c', $date) : $date;
     // Call the DateTime constructor.
     parent::__construct($date, $tz);
     // Reset the timezone for 3rd party libraries/extension that does not use JDate
     date_default_timezone_set(self::$stz->getName());
     // Set the timezone object for access later.
     $this->tz = $tz;
 }
开发者ID:edrdesigner,项目名称:awf,代码行数:31,代码来源:Date.php

示例2: setTimezone

 public function setTimezone($timezone)
 {
     $this->timezone = $timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone);
     $this->TZID = $this->timezone->getName();
     list($standardTransition, $daylightTransition) = $transitions = $this->_getTransitionsForTimezoneAndYear($this->timezone, date('Y'));
     $dtstart = new Sabre_VObject_Property_DateTime('DTSTART');
     $dtstart->setDateTime(new DateTime(), Sabre_VObject_Element_DateTime::LOCAL);
     if ($daylightTransition !== null) {
         $offsetTo = ($daylightTransition['offset'] < 0 ? '-' : '+') . strftime('%H%M', abs($daylightTransition['offset']));
         $offsetFrom = ($standardTransition['offset'] < 0 ? '-' : '+') . strftime('%H%M', abs($standardTransition['offset']));
         $daylight = new Sabre_VObject_Component('DAYLIGHT');
         $daylight->TZOFFSETFROM = $offsetFrom;
         $daylight->TZOFFSETTO = $offsetTo;
         $daylight->TZNAME = $daylightTransition['abbr'];
         $daylight->DTSTART = $dtstart;
         #$daylight->RRULE       = 'FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3';
         $this->add($daylight);
     }
     if ($standardTransition !== null) {
         $offsetTo = ($standardTransition['offset'] < 0 ? '-' : '+') . strftime('%H%M', abs($standardTransition['offset']));
         if ($daylightTransition !== null) {
             $offsetFrom = ($daylightTransition['offset'] < 0 ? '-' : '+') . strftime('%H%M', abs($daylightTransition['offset']));
         } else {
             $offsetFrom = $offsetTo;
         }
         $standard = new Sabre_VObject_Component('STANDARD');
         $standard->TZOFFSETFROM = $offsetFrom;
         $standard->TZOFFSETTO = $offsetTo;
         $standard->TZNAME = $standardTransition['abbr'];
         $standard->DTSTART = $dtstart;
         #$standard->RRULE         = 'FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10';
         $this->add($standard);
     }
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:34,代码来源:VTimezone.php

示例3: getPrettyTimezoneName

 /**
  * Get a user-friendly timezone name
  * @param  \DateTimeZone $timezone The timezone
  * @return string
  */
 private function getPrettyTimezoneName(\DateTimeZone $timezone)
 {
     $offset = $timezone->getOffset(new \DateTime('now'));
     if ($offset == 0) {
         $formattedOffset = 'GMT';
     } else {
         $sign = $offset > 0 ? '+' : '-';
         $formattedOffset = 'GMT' . $sign . date('H:i', mktime(0, abs($offset) / 60));
     }
     if (substr($timezone->getName(), 0, 7) === 'Etc/GMT') {
         // Just return the GMT+02:00 text for hardcoded timezone offsets
         return $formattedOffset;
     } else {
         return "({$formattedOffset}) " . $timezone->getName();
     }
 }
开发者ID:blast007,项目名称:bzion,代码行数:21,代码来源:TimezoneType.php

示例4: dodajZdarzenieAction

 /**
  * @Route("/dodaj_zdarzenie", name="dodaj_zdarzenie", options={"expose"=true})
  * @param Request $request
  * @return Response
  */
 public function dodajZdarzenieAction(Request $request)
 {
     $time_zone = new \DateTimeZone('UTC');
     $time_zone->getName();
     $dane = new Zdarzenia();
     $start = new \DateTime($request->get('start'));
     //$start->createFromFormat('ATOM', $request->get('start'),$time_zone);
     $end = new \DateTime($request->get('end'));
     //$end->createFromFormat('ATOM', $request->get('end'),$time_zone);
     $dane->setTitle($request->get('title'));
     $dane->setDescription($request->get('description'));
     $dane->setLocation($request->get('location'));
     $dane->setContact($request->get('contact'));
     $dane->setUrl($request->get('url'));
     $dane->setStart($start);
     $dane->setEnd($end);
     $dane->setAlldayevent($request->get('alldayevent'));
     $em = $this->getDoctrine()->getManager();
     $em->persist($dane);
     $em->flush();
     $response = new \Symfony\Component\HttpFoundation\Response();
     $response->headers->set('Content-Type', 'application/json');
     $response->setContent(json_encode($dane));
     return $response;
 }
开发者ID:szymon-m,项目名称:logopedia,代码行数:30,代码来源:CalendarController.php

示例5: fromString

 /**
  * 
  * @param string $pValue
  * @param \DateTimeZone $pDateTimeZone
  * @return \DateTime
  */
 public function fromString($pValue, \DateTimeZone $pDateTimeZone)
 {
     $lDateTime = new \DateTime($pValue, $pDateTimeZone);
     if ($lDateTime->getTimezone()->getName() !== $pDateTimeZone->getName()) {
         $lDateTime->setTimezone($pDateTimeZone);
     }
     return $lDateTime;
 }
开发者ID:jeanphilippe-p,项目名称:ObjectManagerLib,代码行数:14,代码来源:DateTime.php

示例6: formatted_time

function formatted_time($datetime_str = 'now', $timestamp_format = NULL, $timezone = NULL)
{
    $tz = new DateTimeZone($timezone ? $timezone : date_default_timezone_get());
    $time = new DateTime($datetime_str, $tz);
    if ($time->getTimeZone()->getName() !== $tz->getName()) {
        $time->setTimeZone($tz);
    }
    return $time->format($timestamp_format);
}
开发者ID:badlamer,项目名称:hhvm,代码行数:9,代码来源:formatted_time.php

示例7: __construct

 /**
  * Constructor.
  *
  * @param Carbon|null $after
  * @param Carbon|null $before
  * @param null|string $name
  *
  * @throws TimezoneException|DateRangeException
  */
 public function __construct(Carbon $after = null, Carbon $before = null, $name = null)
 {
     $this->name = $name;
     $this->after = $after;
     $this->before = $before;
     if (is_null($after) && is_null($before)) {
         throw new DateRangeException('Either an after date or before date must be provided.');
     } elseif (is_null($after) && !is_null($before)) {
         $this->timezone = $before->getTimezone();
     } elseif (is_null($before)) {
         $this->timezone = $after->getTimezone();
     } else {
         $this->timezone = $this->after->getTimezone();
         $before_tz = is_null($this->before->getTimezone()) ? null : $this->before->getTimezone();
         if ($before_tz->getName() !== $this->timezone->getName()) {
             throw new TimezoneException('Multiple timezones are not supported.');
         }
     }
 }
开发者ID:20TRIES,项目名称:date_range,代码行数:28,代码来源:DateRange.php

示例8: cases__construct

 /**
  * Test Cases for __construct
  *
  * @return  array
  *
  * @since   11.3
  */
 public function cases__construct()
 {
     $cases = array('basic' => array('12/23/2008 13:45', null, 'Tue 12/23/2008 13:45'), 'tzCT' => array('12/23/2008 13:45', 'US/Central', 'Tue 12/23/2008 13:45'), 'DateTime tzCT' => array('12/23/2008 13:45', new DateTimeZone('US/Central'), 'Tue 12/23/2008 13:45'));
     // Backup the default timezone before continuing - Using the system timezone apparently causes test failures
     $timezone = new DateTimeZone(date_default_timezone_get());
     date_default_timezone_set('UTC');
     $cases['unix'] = array(strtotime('12/26/2008 13:45'), null, 'Fri 12/26/2008 13:45');
     // Restore the timezone
     date_default_timezone_set($timezone->getName());
     return $cases;
 }
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:18,代码来源:JDateTest.php

示例9: setTimezone

 /**
  * Verifies that the given timezone exists and sets the timezone to the selected timezone
  *
  * @TODO Verify that the given timezone exists
  *
  * @param string $timezoneName
  * @return string
  */
 public function setTimezone($timeZoneName = 'UTC')
 {
     if (!$this->isValidTimeZone($timeZoneName)) {
         $timeZoneName = 'UTC';
     }
     $this->timezone = new \DateTimeZone($timeZoneName);
     $this->timezoneId = $this->timezone->getName();
     $transitions = $this->timezone->getTransitions();
     $this->timezoneInDST = $transitions[0]['isdst'];
     return $this->timezoneId;
 }
开发者ID:unreal4u,项目名称:localization,代码行数:19,代码来源:localization.php

示例10: toRaw

 /**
  * @return array
  */
 public function toRaw()
 {
     $fromDate = clone $this->fromDate;
     $fromDate->setTimezone($this->timezone);
     $toDate = clone $this->toDate;
     $toDate->setTimezone($this->timezone);
     $requestParams = ['tzid' => $this->timezone->getName(), 'from' => $fromDate->format('Y-m-d'), 'to' => $toDate->format('Y-m-d')];
     if ($this->calendars !== null) {
         $requestParams['calendar_ids'] = $this->calendars;
     }
     return $requestParams;
 }
开发者ID:geekdevs,项目名称:oauth2-cronofy,代码行数:15,代码来源:EventCriteria.php

示例11: __construct

 /**
  * Creates a new component.
  *
  * By default this object will iterate over its own children, but this can 
  * be overridden with the iterator argument
  * 
  * @param string $name 
  * @param Sabre\VObject\ElementList $iterator
  */
 public function __construct()
 {
     parent::__construct();
     $tz = new \DateTimeZone(\GO::user() ? \GO::user()->timezone : date_default_timezone_get());
     //$tz = new \DateTimeZone("Europe/Amsterdam");
     $transitions = $tz->getTransitions();
     $start_of_year = mktime(0, 0, 0, 1, 1);
     $to = \GO\Base\Util\Date::get_timezone_offset(time());
     if ($to < 0) {
         if (strlen($to) == 2) {
             $to = '-0' . $to * -1;
         }
     } else {
         if (strlen($to) == 1) {
             $to = '0' . $to;
         }
         $to = '+' . $to;
     }
     $STANDARD_TZOFFSETFROM = $STANDARD_TZOFFSETTO = $DAYLIGHT_TZOFFSETFROM = $DAYLIGHT_TZOFFSETTO = $to;
     $STANDARD_RRULE = '';
     $DAYLIGHT_RRULE = '';
     for ($i = 0, $max = count($transitions); $i < $max; $i++) {
         if ($transitions[$i]['ts'] > $start_of_year) {
             $weekday1 = $this->_getDay($transitions[$i]['time']);
             $weekday2 = $this->_getDay($transitions[$i + 1]['time']);
             if ($transitions[$i]['isdst']) {
                 $dst_start = $transitions[$i];
                 $dst_end = $transitions[$i + 1];
             } else {
                 $dst_end = $transitions[$i];
                 $dst_start = $transitions[$i + 1];
             }
             $STANDARD_TZOFFSETFROM = $this->_formatVtimezoneTransitionHour($dst_start['offset'] / 3600);
             $STANDARD_TZOFFSETTO = $this->_formatVtimezoneTransitionHour($dst_end['offset'] / 3600);
             $DAYLIGHT_TZOFFSETFROM = $this->_formatVtimezoneTransitionHour($dst_end['offset'] / 3600);
             $DAYLIGHT_TZOFFSETTO = $this->_formatVtimezoneTransitionHour($dst_start['offset'] / 3600);
             $DAYLIGHT_RRULE = "FREQ=YEARLY;BYDAY={$weekday1};BYMONTH=" . date('n', $dst_start['ts']);
             $STANDARD_RRULE = "FREQ=YEARLY;BYDAY={$weekday2};BYMONTH=" . date('n', $dst_end['ts']);
             break;
         }
     }
     $this->tzid = $tz->getName();
     //	$this->add("last-modified", "19870101T000000Z");
     $rrule = new \Sabre\VObject\Recur\RRuleIterator($STANDARD_RRULE, new \DateTime('1970-01-01 ' . substr($STANDARD_TZOFFSETFROM, 1) . ':00'));
     $rrule->next();
     $rrule->next();
     $this->add($this->createComponent("standard", array('dtstart' => $rrule->current()->format('Ymd\\THis'), 'rrule' => $STANDARD_RRULE, 'tzoffsetfrom' => $STANDARD_TZOFFSETFROM . "00", 'tzoffsetto' => $STANDARD_TZOFFSETTO . "00")));
     $rrule = new \Sabre\VObject\Recur\RRuleIterator($DAYLIGHT_RRULE, new \DateTime('1970-01-01 ' . substr($DAYLIGHT_TZOFFSETFROM, 1) . ':00'));
     $rrule->next();
     $rrule->next();
     $this->add($this->createComponent("daylight", array('dtstart' => $rrule->current()->format('Ymd\\THis'), 'rrule' => $DAYLIGHT_RRULE, 'tzoffsetfrom' => $DAYLIGHT_TZOFFSETFROM . "00", 'tzoffsetto' => $DAYLIGHT_TZOFFSETTO . "00")));
 }
开发者ID:ajaboa,项目名称:crmpuan,代码行数:61,代码来源:VTimezone.php

示例12: _actionRun

 /**
  * Run the application
  *
  * @param Library\CommandContext $context	A command context object
  */
 protected function _actionRun(Library\CommandContext $context)
 {
     //Set the site error reporting
     $this->getEventDispatcher()->setDebugMode($this->getCfg('debug_mode'));
     //Set the paths
     $params = $this->getObject('application.extensions')->files->params;
     define('JPATH_FILES', JPATH_SITES . '/' . $this->getSite() . '/files');
     define('JPATH_CACHE', $this->getCfg('cache_path', JPATH_ROOT . '/cache'));
     // Set timezone to user's setting, falling back to global configuration.
     $timezone = new \DateTimeZone($context->user->get('timezone', $this->getCfg('timezone')));
     date_default_timezone_set($timezone->getName());
     //Route the request
     $this->route();
 }
开发者ID:janssit,项目名称:www.rvproductions.be,代码行数:19,代码来源:http.php

示例13: adjustTimeZone

    protected function adjustTimeZone()
    {
        $item_list = $this->getItemList('integer');
        $date = new SwatDate();
        $photo_tz = new DateTimeZone($this->ui->getWidget('photo_time_zone')->value);
        $camera_tz = new DateTimeZone($this->ui->getWidget('camera_time_zone')->value);
        $photo_offset = $photo_tz->getOffset($date);
        $camera_offset = $camera_tz->getOffset($date);
        $offset_s = $photo_offset - $camera_offset;
        $instance_id = $this->app->getInstanceId();
        $sql = sprintf('update PinholePhoto set photo_time_zone = %s,
			photo_date = convertToUTC(convertTZ(photo_date, photo_time_zone)
				+ interval %s, %s)
			where PinholePhoto.image_set in (
				select id from ImageSet where instance %s %s)', $this->app->db->quote($photo_tz->getName(), 'text'), $this->app->db->quote($offset_s . ' seconds', 'text'), $this->app->db->quote($photo_tz->getName(), 'text'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'));
        // note the only page with an extended-selection that accesses this
        // is the pending photos page - so enforce status here.
        if ($this->extended_selected) {
            $sql .= sprintf(' and PinholePhoto.status = %s', $this->app->db->quote(PinholePhoto::STATUS_PENDING, 'integer'));
        } else {
            $sql .= sprintf(' and PinholePhoto.id in (%s)', $item_list);
        }
        return SwatDB::exec($this->app->db, $sql);
    }
开发者ID:gauthierm,项目名称:pinhole,代码行数:24,代码来源:Time.php

示例14: dzisiajAction

 /**
  * @Route("/dzisiaj", name="dzisiaj", options={"expose"=true})
  * @Template("LogopediaBundle:Spotkanie:dzisiaj.html.twig")
  */
 public function dzisiajAction()
 {
     $time_zone = new \DateTimeZone('UTC');
     $time_zone->getName();
     // definiujemy dzisiejszy dzień
     $poczatek = new \DateTime();
     $poczatek->setTime(00, 00, 00);
     $koniec = new \DateTime();
     $koniec->setTime(23, 59, 59);
     $em = $this->getDoctrine()->getManager();
     $query = $em->createQuery('SELECT s, p
              FROM LogopediaBundle:Spotkanie s
               JOIN s.idPacjenta p
               WHERE s.start >= :poczatek
               AND s.end <= :koniec
               ORDER BY s.start ASC')->setParameters(array('poczatek' => $poczatek, 'koniec' => $koniec));
     $dzisiaj = $query->getResult();
     return array('dzisiaj' => $dzisiaj);
 }
开发者ID:szymon-m,项目名称:logopedia,代码行数:23,代码来源:SpotkanieController.php

示例15: __construct

 public function __construct($useMicroseconds, \DateTimeZone $timezone = null)
 {
     $this->useMicroseconds = $useMicroseconds;
     $date = 'now';
     if ($useMicroseconds) {
         $timestamp = microtime(true);
         // apply offset of the timezone as microtime() is always UTC
         if ($timezone && $timezone->getName() !== 'UTC') {
             $timestamp += (new \DateTime('now', $timezone))->getOffset();
         }
         // Circumvent DateTimeImmutable::createFromFormat() which always returns \DateTimeImmutable instead of `static`
         // @link https://bugs.php.net/bug.php?id=60302
         //
         // So we create a DateTime but then format it so we
         // can re-create one using the right class
         $dt = self::createFromFormat('U.u', sprintf('%.6F', $timestamp));
         $date = $dt->format('Y-m-d H:i:s.u');
     }
     parent::__construct($date, $timezone);
 }
开发者ID:earncef,项目名称:monolog,代码行数:20,代码来源:DateTimeImmutable.php


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