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


PHP date_default_timezone_get函数代码示例

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


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

示例1: run

 public static function run()
 {
     spl_autoload_register(['Bootstrap', 'autoload']);
     putenv('LANG=en_US.UTF-8');
     setlocale(LC_CTYPE, 'en_US.UTF-8');
     date_default_timezone_set(@date_default_timezone_get());
     session_start();
     $session = new Session($_SESSION);
     $request = new Request($_REQUEST);
     $setup = new Setup($request->query_boolean('refresh', false));
     $context = new Context($session, $request, $setup);
     if ($context->is_api_request()) {
         (new Api($context))->apply();
     } else {
         if ($context->is_info_request()) {
             $public_href = $setup->get('PUBLIC_HREF');
             $x_head_tags = $context->get_x_head_html();
             require __DIR__ . '/pages/info.php';
         } else {
             $public_href = $setup->get('PUBLIC_HREF');
             $x_head_tags = $context->get_x_head_html();
             $fallback_html = (new Fallback($context))->get_html();
             require __DIR__ . '/pages/index.php';
         }
     }
 }
开发者ID:arter97,项目名称:h5ai,代码行数:26,代码来源:class-bootstrap.php

示例2: __construct

 public function __construct()
 {
     $this->fmt = new IntlDateFormatter('nl_BE', IntlDateFormatter::FULL, IntlDateFormatter::FULL, date_default_timezone_get(), IntlDateFormatter::GREGORIAN, 'd MMMM yyyy');
     $this->fmtWeekDayLong = new IntlDateFormatter('nl_BE', IntlDateFormatter::FULL, IntlDateFormatter::FULL, date_default_timezone_get(), IntlDateFormatter::GREGORIAN, 'EEEE');
     $this->fmtWeekDayShort = new IntlDateFormatter('nl_BE', IntlDateFormatter::FULL, IntlDateFormatter::FULL, date_default_timezone_get(), IntlDateFormatter::GREGORIAN, 'EEEEEE');
     $this->fmtTime = new IntlDateFormatter('nl_BE', IntlDateFormatter::FULL, IntlDateFormatter::FULL, date_default_timezone_get(), IntlDateFormatter::GREGORIAN, 'HH:mm');
 }
开发者ID:cultuurnet,项目名称:calendar-summary,代码行数:7,代码来源:LargeTimestampsHTMLFormatter.php

示例3: getTimezone

 /**
  * Gets the default timezone to be used by the date filter.
  *
  * @return DateTimeZone The default timezone currently in use
  */
 public function getTimezone()
 {
     if (null === $this->timezone) {
         $this->timezone = new DateTimeZone(date_default_timezone_get());
     }
     return $this->timezone;
 }
开发者ID:stler,项目名称:NMFrame,代码行数:12,代码来源:Core.php

示例4: mapComponents

 /**
  * @param array $components
  */
 private function mapComponents(array $components)
 {
     foreach ($components as $component) {
         $this->components[(string) $component] = $component;
     }
     $this->timezone = date_default_timezone_get();
 }
开发者ID:genkgo,项目名称:xsl,代码行数:10,代码来源:IntlDateTimeFormatter.php

示例5: configure

 /**
  * {@inheritDoc}
  */
 protected function configure()
 {
     $this->addOption('input_timezone', date_default_timezone_get());
     $this->addOption('output_timezone', date_default_timezone_get());
     $this->addOption('format', 'Y-m-d H:i:s');
     parent::configure();
 }
开发者ID:noelg,项目名称:symfony-demo,代码行数:10,代码来源:DateTimeToStringTransformer.php

示例6: _init

	public static function _init()
	{
		static::$server_gmt_offset	= \Config::get('server_gmt_offset', 0);

		// Set the default timezone
		static::$default_timezone	= date_default_timezone_get();

		// Ugly temporary windows fix because windows doesn't support strptime()
		// Better fix will accept custom pattern parsing but only parse numeric input on windows servers
		if ( ! function_exists('strptime') && ! function_exists('Fuel\Core\strptime'))
		{
			function strptime($input, $format)
			{
				$ts = strtotime($input);
				return array(
					'tm_year'	=> date('Y', $ts),
					'tm_mon'	=> date('n', $ts),
					'tm_mday'	=> date('j', $ts),
					'tm_hour'	=> date('H', $ts),
					'tm_min'	=> date('i', $ts),
					'tm_sec'	=> date('s', $ts)
				);
				// This really is some fugly code, but someone at PHP HQ decided strptime should
				// output this awful array instead of a timestamp LIKE EVERYONE ELSE DOES!!!
			}
		}
	}
开发者ID:nasumi,项目名称:fuel,代码行数:27,代码来源:date.php

示例7: initTimezone

 /**
  * Initialize the timezone.
  *
  * This function should be called before any calls to date().
  *
  * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
  */
 public static function initTimezone()
 {
     static $initialized = false;
     if ($initialized) {
         return;
     }
     $initialized = true;
     $globalConfig = \SimpleSAML_Configuration::getInstance();
     $timezone = $globalConfig->getString('timezone', null);
     if ($timezone !== null) {
         if (!date_default_timezone_set($timezone)) {
             throw new \SimpleSAML_Error_Exception('Invalid timezone set in the "timezone" option in config.php.');
         }
         return;
     }
     // we don't have a timezone configured
     /*
      * The date_default_timezone_get() function is likely to cause a warning.
      * Since we have a custom error handler which logs the errors with a backtrace,
      * this error will be logged even if we prefix the function call with '@'.
      * Instead we temporarily replace the error handler.
      */
     set_error_handler(function () {
         return true;
     });
     $serverTimezone = date_default_timezone_get();
     restore_error_handler();
     // set the timezone to the default
     date_default_timezone_set($serverTimezone);
 }
开发者ID:palantirnet,项目名称:simplesamlphp,代码行数:37,代码来源:Time.php

示例8: initialBasicFixes

/**
* Fix basic php issues and check version
*/
function initialBasicFixes()
{
    /**
     * bypass date & timezone-related warnings with php 5.1
     */
    if (function_exists('date_default_timezone_set')) {
        $tz = @date_default_timezone_get();
        date_default_timezone_set($tz);
    }
    ini_set('zend.ze1_compatibility_mode', 0);
    ini_set("pcre.backtrack_limit", -1);
    # fix 5.2.0 prce bug with render_wiki
    if (function_exists('mb_internal_encoding')) {
        mb_internal_encoding("UTF-8");
    }
    #ini_set("mbstring.func_overload", 2);
    /**
     * add rough php-version check to at least avoid parsing errors.
     * fine version-check follows further down
     */
    if (phpversion() < "5.0.0") {
        echo "Sorry, but Streber requires php5 or higher.";
        exit;
    }
}
开发者ID:Bremaweb,项目名称:streber-1,代码行数:28,代码来源:initial_setup.inc.php

示例9: __construct

 /**
  * Date constructor.
  *
  * @param \ACP3\Core\Date\DateTranslator $dateTranslator
  */
 public function __construct(DateTranslator $dateTranslator)
 {
     $this->dateTranslator = $dateTranslator;
     $defaultTimeZone = date_default_timezone_get();
     $settings = ['date_format_long' => 'd.m.y, H:i', 'date_format_short' => 'd.m.y', 'time_zone' => !empty($defaultTimeZone) ? $defaultTimeZone : 'UTC'];
     $this->setFormatAndTimeZone($settings);
 }
开发者ID:acp3,项目名称:setup,代码行数:12,代码来源:Date.php

示例10: updateTime

function updateTime()
{
    // date_default_timezone_set('America/New_York');
    echo date_default_timezone_get() . "<br>";
    $date = date('m/d/Y h:i:s a', time());
    echo getTime();
}
开发者ID:johnjp15,项目名称:WEB_DEV,代码行数:7,代码来源:visitpage.php

示例11: _formatVarAsJSON

 private function _formatVarAsJSON($var)
 {
     if (is_scalar($var) || is_null($var)) {
         return $var;
     }
     if (is_array($var)) {
         foreach ($var as $index => $value) {
             $var[$index] = $this->_formatVarAsJSON($value);
         }
         return $var;
     }
     if (is_object($var)) {
         $this->_paramIndex++;
         switch (get_class($var)) {
             case "MongoId":
                 $this->_jsonParams[$this->_paramIndex] = 'ObjectId("' . $var->__toString() . '")';
                 return $this->_param($this->_paramIndex);
             case "MongoDate":
                 $timezone = date_default_timezone_get();
                 date_default_timezone_set("UTC");
                 $this->_jsonParams[$this->_paramIndex] = "ISODate(\"" . date("Y-m-d", $var->sec) . "T" . date("H:i:s.", $var->sec) . $var->usec / 1000 . "Z\")";
                 date_default_timezone_set($timezone);
                 return $this->_param($this->_paramIndex);
             default:
                 if (method_exists($var, "__toString")) {
                     return $var->__toString();
                 }
                 return '<unknown type>';
         }
     }
 }
开发者ID:navruzm,项目名称:navruz.net,代码行数:31,代码来源:Mongo_export.php

示例12: setUp

    protected function setUp()
    {
        $this->_originaltimezone = date_default_timezone_get();
    	date_default_timezone_set('Europe/Berlin');

        if (isset($_SERVER['SERVER_NAME'])) {
            $this->_oldServer['SERVER_NAME'] = $_SERVER['SERVER_NAME'];
        }

        if (isset($_SERVER['SERVER_PORT'])) {
            $this->_oldServer['SERVER_PORT'] = $_SERVER['SERVER_PORT'];
        }

        if (isset($_SERVER['REQUEST_URI'])) {
            $this->_oldServer['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
        }

        $_SERVER['SERVER_NAME'] = 'localhost';
        $_SERVER['SERVER_PORT'] = 80;
        $_SERVER['REQUEST_URI'] = '/';

        $this->_front = \Zend\Controller\Front::getInstance();
        $this->_oldRequest = $this->_front->getRequest();
        $this->_oldRouter = $this->_front->getRouter();

        $this->_front->resetInstance();
        $this->_front->setRequest(new Request\Http());
        $this->_front->getRouter()->addDefaultRoutes();

        parent::setUp();

        $this->_helper->setFormatOutput(true);
    }
开发者ID:noose,项目名称:zf2,代码行数:33,代码来源:SitemapTest.php

示例13: setUp

 public function setUp()
 {
     // Set timezone to support timestamp->date conversion.
     $this->originalTZ = date_default_timezone_get();
     date_default_timezone_set('Pacific/Auckland');
     parent::setUp();
 }
开发者ID:SpiritLevel,项目名称:silverstripe-framework,代码行数:7,代码来源:DBDateTest.php

示例14: setDateTime

 /**
  * Sets date/time
  *
  * @param \DateTime|string $datetime
  * @param string           $fromFormat
  * @param string           $timezone
  */
 public function setDateTime($datetime = '', $fromFormat = 'Y-m-d H:i:s', $timezone = 'local')
 {
     if ($timezone == 'local') {
         $timezone = date_default_timezone_get();
     } elseif (empty($timezone)) {
         $timezone = 'UTC';
     }
     $this->format = empty($fromFormat) ? 'Y-m-d H:i:s' : $fromFormat;
     $this->timezone = $timezone;
     $this->utc = new \DateTimeZone('UTC');
     $this->local = new \DateTimeZone(date_default_timezone_get());
     if ($datetime instanceof \DateTime) {
         $this->datetime = $datetime;
         $this->string = $this->datetime->format($fromFormat);
     } elseif (empty($datetime)) {
         $this->datetime = new \DateTime('now', new \DateTimeZone($this->timezone));
         $this->string = $this->datetime->format($fromFormat);
     } elseif ($fromFormat == null) {
         $this->string = $datetime;
         $this->datetime = new \DateTime($datetime, new \DateTimeZone($this->timezone));
     } else {
         $this->string = $datetime;
         $this->datetime = \DateTime::createFromFormat($this->format, $this->string, new \DateTimeZone($this->timezone));
         if ($this->datetime === false) {
             //the format does not match the string so let's attempt to fix that
             $this->string = date($this->format, strtotime($datetime));
             $this->datetime = \DateTime::createFromFormat($this->format, $this->string);
         }
     }
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:37,代码来源:DateTimeHelper.php

示例15: remove_exclusions

 /**
  * Accepts an array of $date_durations and removes any falling on the dates listed
  * within $exclusion_dates.
  *
  * Both parameters are arrays of arrays, each inner array or "date duration" taking the
  * following form:
  *
  *     [ 'timestamp' => int,
  *       'duration'  => int  ]
  *
  * In the case of exclusions, duration will always be zero as custom exclusions do
  * not currently support custom durations, so that element is ignored during comparison.
  *
  * @param array $date_durations
  * @param array $exclusion_dates
  *
  * @return array
  */
 public function remove_exclusions(array $date_durations, array $exclusion_dates)
 {
     $date_default_timezone = date_default_timezone_get();
     $timezone_identifier = $this->timezone_string;
     $timezone_slip = 0;
     $matches = array();
     preg_match('/^UTC(\\+|-)+(\\d+)+(\\.(\\d+)*)*/', $this->timezone_string, $matches);
     if ($matches) {
         $timezone_identifier = 'UTC';
         $signum = $matches[1];
         $hrs = intval($matches[2]) * 3600;
         $minutes = floatval(empty($matches[3]) ? 0 : $matches[3]) * 3600;
         $timezone_slip = intval($signum . ($hrs + $minutes));
     }
     date_default_timezone_set($timezone_identifier);
     $exclusion_timestamps = array();
     // 24hrs in seconds -1 second
     $almost_one_day = 86399;
     foreach ($exclusion_dates as $exclusion) {
         $start = strtotime('midnight', $exclusion['timestamp']) + $timezone_slip;
         $exclusion_timestamps[] = array('start' => $start, 'end' => $start + $almost_one_day);
     }
     foreach ($date_durations as $key => $date_duration) {
         foreach ($exclusion_timestamps as $exclusion_timestamp) {
             if ($exclusion_timestamp['start'] <= $date_duration['timestamp'] && $date_duration['timestamp'] <= $exclusion_timestamp['end']) {
                 unset($date_durations[$key]);
             }
         }
     }
     $date_durations = array_values($date_durations);
     date_default_timezone_set($date_default_timezone);
     return $date_durations;
 }
开发者ID:jamestrevorlees,项目名称:odd-web-v1.00,代码行数:51,代码来源:Exclusions.php


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