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


PHP JDate::getOffset方法代码示例

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


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

示例1: getUserTime

 /**
  * This will return the user timezone
  * @param int $user_id id of the user
  * @param String $forDisplay get the display, if true then return value will be formatted to the proper display
  * @return String depends on the value of format
  */
 public static function getUserTime($user_id = null, $forDisplay = false)
 {
     $config = new JXConfig();
     $user = JFactory::getUser($user_id);
     // First load account setting (if any) timezone to override timezone in language file
     $defaultTz = $config->getTimezone() != '' ? $config->getTimezone() : JText::_('JXLIB_DEFAULT_TIMEZONE');
     $my = !$user instanceof JUser && !$user instanceof JXUser ? JXFactory::getUser() : $user;
     $timeZoneStr = $my->getParam('timezone');
     // Second load user personalize timezone (if any) to override system default timezone
     $timeZoneStr = empty($timeZoneStr) ? $defaultTz : $timeZoneStr;
     $tz = new DateTimeZone($timeZoneStr);
     $date2 = new JDate('now', $tz);
     $offset = $date2->getOffset() / 3600;
     $date = new JDate();
     $date->setOffset($offset);
     $xdate = new JXDate();
     /* if the value want to be used as display purposes */
     if ($forDisplay) {
         return $xdate->formatDate($date);
     } else {
         return $xdate->format($date);
     }
 }
开发者ID:ErickLopez76,项目名称:offiria,代码行数:29,代码来源:xuser.php

示例2: get

 /**
  *
  * $range array('month' => 2)	 
  */
 public static function get($actions, $user_id, $group_id, $range, $group_by)
 {
     if ($group_by == 'hour') {
         // todo: db datetime is server utc, might need to calculate for offset
         $config = new JXConfig();
         $defaultTz = $config->getTimezone() != '' ? $config->getTimezone() : JText::_('JXLIB_DEFAULT_TIMEZONE');
         $my = JXFactory::getUser($user_id);
         $myTimeZone = $my->getParam('timezone');
         // Second load user personalize timezone (if any) to override system default timezone
         $timeZoneStr = empty($myTimeZone) ? $defaultTz : $myTimeZone;
         $tz = new DateTimeZone($timeZoneStr);
         $date2 = new JDate('now', $tz);
         $offset = $date2->getOffset() / 3600;
     } else {
         $offset = 0;
     }
     $result = self::getDbRecord($actions, $user_id, $group_id, $range, $group_by, $offset);
     return self::formulateData($result, $group_by, $offset);
 }
开发者ID:ErickLopez76,项目名称:offiria,代码行数:23,代码来源:analytics.php

示例3: formatDate

 /**
  * Return standardized formatted date
  * NOTE: FOR TEMPLATE DISPLAY PURPOSE ONLY!!! DO NOT USE FOR DB QUERIES
  * Also use only for server generated time, NOT	 
  */
 static function formatDate($date, $long = self::LONG_DATE_FORMAT, $user = null)
 {
     // return original input date that cannot be processed
     if (strtotime($date) === false) {
         return $date;
     }
     $config = new JXConfig();
     // First load account setting (if any) timezone to override timezone in language file
     $defaultTz = $config->getTimezone() != '' ? $config->getTimezone() : JText::_('JXLIB_DEFAULT_TIMEZONE');
     $my = !$user instanceof JUser && !$user instanceof JXUser ? JXFactory::getUser() : $user;
     $timeZoneStr = $my->getParam('timezone');
     // Second load user personalize timezone (if any) to override system default timezone
     $timeZoneStr = empty($timeZoneStr) ? $defaultTz : $timeZoneStr;
     $tz = new DateTimeZone($timeZoneStr);
     if ($date instanceof JDate) {
         $date = $date->format('Y-m-d h:i:s');
     }
     $datenow = new JDate('now', $tz);
     $offset = $datenow->getOffset() / 3600;
     $date = new JDate($date);
     $date->setOffset($offset);
     $dateStr = $long == self::LONG_DATE_FORMAT ? $date->format(JText::_('JXLIB_DATE_FORMAT'), true) : $date->format(JText::_('JXLIB_DATE_SHORT_FORMAT'), true);
     if ($long == self::LONG_DATE_FORMAT) {
         // Test for today
         $dmy = $datenow->format(JText::_('JXLIB_DATE_DMY'), true);
         $dateStr = str_replace($dmy, JText::_('JXLIB_DATE_TODAY'), $dateStr);
         // Test for yesterday
         $datenow->modify('-1 day');
         $dmy = $datenow->format(JText::_('JXLIB_DATE_DMY'), true);
         $dateStr = str_replace($dmy, JText::_('JXLIB_DATE_YESTERDAY'), $dateStr);
     }
     return $dateStr;
 }
开发者ID:ErickLopez76,项目名称:offiria,代码行数:38,代码来源:xdate.php

示例4: getOffset

 public function getOffset($hours = false)
 {
     return C_JOOMLA_15 == 1 ? parent::getOffset() : parent::getOffsetFromGMT($hours);
 }
开发者ID:Simarpreet05,项目名称:joomla,代码行数:4,代码来源:time.php


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