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


PHP Time::FormatGMT方法代码示例

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


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

示例1: HookRenderPage

 /**
  * Hook on the page render, use this to look for generic metadata and map those over to opengraph data.
  *
  * @param View $view
  */
 public static function HookRenderPage(View $view)
 {
     if (!isset($view->meta['og:type'])) {
         $view->meta['og:type'] = 'website';
     }
     if (!isset($view->meta['og:title'])) {
         $view->meta['og:title'] = $view->title;
     }
     if ($view->canonicalurl) {
         $view->meta['og:url'] = $view->canonicalurl;
     }
     if (isset($view->meta['description'])) {
         $view->meta['og:description'] = str_replace(array("\r\n", "\r", "\n"), ' ', $view->meta['description']);
     }
     // Articles can have some specific information.
     if ($view->meta['og:type'] == 'article') {
         $view->meta['og:article:modified_time'] = Time::FormatGMT($view->updated, Time::TIMEZONE_GMT, 'r');
         if (isset($view->meta['author'])) {
             $view->meta['og:article:author'] = $view->meta['author'];
         }
     }
     if (FACEBOOK_APP_ID) {
         $view->meta['fb:app_id'] = FACEBOOK_APP_ID;
     }
     /*
      * other article tags:
     article:published_time - datetime - When the article was first published.
     article:modified_time - datetime - When the article was last changed.
     article:expiration_time - datetime - When the article is out of date after.
     article:author - profile array - Writers of the article.
     article:section - string - A high-level section name. E.g. Technology
     article:tag - string array - Tag words associated with this article.
     */
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:39,代码来源:FacebookHelper.class.php

示例2: monthly

 /**
  * Execute the monthly cron
  */
 public function monthly()
 {
     $request = $this->getPageRequest();
     $view = $this->getView();
     $view->mode = View::MODE_NOOUTPUT;
     // Check and see if I need to run this cron already, ie: don't run an hourly log twice in the same hour.
     $last = CronLogModel::Find(array('cron' => 'monthly'), 1, 'created DESC');
     if ($last && Time::GetCurrentGMT('Ym') == Time::FormatGMT($last->get('created'), Time::TIMEZONE_GMT, 'Ym')) {
         // No run needed, already ran this month.
         // Report this.
         $timelast = floor((Time::GetCurrentGMT() - $last->get('created')) / 60);
         if ($timelast >= 3600 * 48) {
             $timelast = floor((Time::GetCurrentGMT() - $last->get('created')) / 3600 * 24) . ' days';
         } elseif ($timelast >= 120) {
             $timelast = floor((Time::GetCurrentGMT() - $last->get('created')) / 3600) . ' hours';
         } else {
             $timelast .= ' minutes';
         }
         $logmsg = "Not re-running, already executed monthly cron " . $timelast . ' ago';
         SystemLogModel::LogInfoEvent('/cron/monthly', $logmsg);
         return;
     }
     $log = $this->_performcron('monthly');
     if ($log->get('status') != 'pass') {
         echo 'failed, check the logs';
     }
 }
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:30,代码来源:CronController.php

示例3: testTimeFormatGMT

	public function testTimeFormatGMT(){
		$ref = new DateTime(null, new DateTimeZone('UTC'));
		$localref = new DateTime(null, new DateTimeZone(date_default_timezone_get()));

		$this->assertEquals($localref->format('U'), \Time::FormatGMT($ref->format('U'), date_default_timezone_get()));
	}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:6,代码来源:LegacyDateTimeTest.php

示例4: GetRelativeAsString

	/**
	 * Get a string to represent the relative time from right now.
	 * Will return something similar to 'Yesterday at 5:40p' or 'Today at 4:20a', etc...
	 *
	 * @param $time int The time, (in GMT), to get the relative from now.
	 * @param $timezone int The timezone to display the result as.
	 * @param $accuracy int The level of accuracy,
	 *                      2 will return today|yesterday|tomorrow,
	 *                      3 will return up to a week, ie: Monday at 4:40pm
	 * @param $timeformat string The formatting to use for times.
	 * @param $dateformat string The formatting to use for dates.
	 *
	 * @return string
	 */
	public static function GetRelativeAsString($time, $timezone = Time::TIMEZONE_GMT, $accuracy = 3, $timeformat = 'g:ia', $dateformat = 'M j, Y') {
		// First, get the day of now and the time that's being compared.
		// They will form an int in the format of YYYYMMDD.
		$nowStamp = Time::GetCurrent($timezone, 'Ymd');
		$cStamp   = Time::FormatGMT($time, $timezone, 'Ymd');

		// The first couple days will always be converted, today and tomorrow/yesterday.
		if ($nowStamp - $cStamp == 0) return 'Today at ' . Time::FormatGMT($time, $timezone, $timeformat);
		elseif ($nowStamp - $cStamp == 1) return 'Yesterday at ' . Time::FormatGMT($time, $timezone, $timeformat);
		elseif ($nowStamp - $cStamp == -1) return 'Tomorrow at ' . Time::FormatGMT($time, $timezone, $timeformat);

		// If accuracy is the minimum and neither today/tomorrow/yesterday, simply return the date.
		if ($accuracy <= 2) return Time::FormatGMT($time, $timezone, $dateformat);

		// If it's too high/low from a week, just return the date.
		if (abs($nowStamp - $cStamp) > 6) return Time::FormatGMT($time, $timezone, $dateformat);

		// Else, return the day of the week, followed by the time.
		return Time::FormatGMT($time, $timezone, 'l \a\t ' . $timeformat);
	}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:34,代码来源:Time.class.php

示例5: getHeadContent

	/**
	 * Get the content to be inserted into the <head> tag for this view.
	 *
	 * @return string
	 */
	public function getHeadContent(){
		$minified = ConfigHandler::Get('/core/markup/minified');

		// First, the basic ones.
		if($minified){
			$data = array_merge($this->stylesheets, $this->head, $this->scripts['head']);
		}
		else{
			$data = array_merge(
				['<!-- BEGIN STYLESHEET INSERTIONS -->'],
				$this->stylesheets,
				['<!-- END STYLESHEET INSERTIONS -->'],
				['<!-- BEGIN HEAD CONTENT INSERTIONS -->'],
				$this->head,
				['<!-- END HEAD CONTENT INSERTIONS -->'],
				['<!-- BEGIN JAVASCRIPT INSERTIONS -->'],
				$this->scripts['head'],
				['<!-- END JAVASCRIPT INSERTIONS -->']
			);
		}


		// Some of the automatic settings only get set if no errors.
		if($this->error == View::ERROR_NOERROR){

			// Custom meta tag :: http-equiv="last-modified"
			if($this->updated !== null){
				// last-modified is no longer a valid attribute in HTML5
				//$data[] = '<meta http-equiv="last-modified" content="' . Time::FormatGMT($this->updated, Time::TIMEZONE_GMT, Time::FORMAT_RFC2822) . '" />';
				$this->meta['article:modified_time'] = Time::FormatGMT($this->updated, Time::TIMEZONE_GMT, Time::FORMAT_ISO8601);
			}

			// Set the generator metatag, (this is handled internally within the tag)
			$this->meta['generator'] = true;

			// Some standard tags that also have og equivalents.
			if(!isset($this->meta['og:title'])){
				$this->meta['og:title'] = $this->title;
			}

			// Set the canonical url if not set.
			if($this->canonicalurl === null){
				$this->canonicalurl = \Core\resolve_link($this->baseurl);
			}

			// Set the canonical URL in the necessary spots (if it's not in error)
			if($this->canonicalurl !== false){
				$this->meta['canonical'] = $this->canonicalurl;
			}

			$this->meta['og:site_name'] = SITENAME;
		}

		// Merge in the standard meta names and properties now.
		$data = array_merge($data, $this->meta->fetch());


		if ($minified) {
			$out = implode('', $data);
		}
		else {
			$out = '<!-- BEGIN Automatic HEAD generation -->' . "\n\n" . implode("\n", $data) . "\n\n" . '<!-- END Automatic HEAD generation -->';
		}

		return trim($out);
	}
开发者ID:nicholasryan,项目名称:CorePlus,代码行数:71,代码来源:View.class.php


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