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


PHP MWTimestamp::offsetForUser方法代码示例

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


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

示例1: getHumanTimestamp

 /**
  * Get the timestamp in a human-friendly relative format, e.g., "3 days ago".
  *
  * Determine the difference between the timestamp and the current time, and
  * generate a readable timestamp by returning "<N> <units> ago", where the
  * largest possible unit is used.
  *
  * @since 1.26 (Prior to 1.26 method existed but was not meant to be used directly)
  *
  * @param MWTimestamp $time
  * @param MWTimestamp|null $relativeTo The base timestamp to compare to (defaults to now)
  * @param User|null $user User the timestamp is being generated for (or null to use main context's user)
  * @return string Formatted timestamp
  */
 public function getHumanTimestamp(MWTimestamp $time, MWTimestamp $relativeTo = null, User $user = null)
 {
     if ($relativeTo === null) {
         $relativeTo = new MWTimestamp();
     }
     if ($user === null) {
         $user = RequestContext::getMain()->getUser();
     }
     // Adjust for the user's timezone.
     $offsetThis = $time->offsetForUser($user);
     $offsetRel = $relativeTo->offsetForUser($user);
     $ts = '';
     if (Hooks::run('GetHumanTimestamp', array(&$ts, $time, $relativeTo, $user, $this))) {
         $ts = $this->getHumanTimestampInternal($time, $relativeTo, $user);
     }
     // Reset the timezone on the objects.
     $time->timestamp->sub($offsetThis);
     $relativeTo->timestamp->sub($offsetRel);
     return $ts;
 }
开发者ID:nanasess,项目名称:mediawiki,代码行数:34,代码来源:Language.php

示例2: getUserLocalTime

 /**
  * Internal helper function for converting UTC timezone to a user's timezone
  * @param $user User
  * @param $ts string
  * @param $format output format
  */
 private static function getUserLocalTime($user, $ts, $format = TS_MW)
 {
     $timestamp = new MWTimestamp($ts);
     $timestamp->offsetForUser($user);
     return $timestamp->getTimestamp($format);
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:12,代码来源:ApiEchoNotifications.php


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