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


PHP JDate::setOffset方法代码示例

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


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

示例1: authenticate

 /**
  * Tries to authenticate the user and start the backup, or send him back to the default task
  */
 function authenticate()
 {
     // Enforce raw mode - I need to be in full control!
     $format = JRequest::getCmd('format', 'html');
     if ($format != 'raw') {
         $this->setRedirect(JURI::base() . 'index.php?option=com_joomlapack&view=light&format=raw');
         parent::redirect();
     } else {
         if (!$this->_checkPermissions()) {
             parent::redirect();
         } else {
             $this->_setProfile();
             jimport('joomla.utilities.date');
             jpimport('core.cube');
             JoomlapackCUBE::reset();
             $cube =& JoomlapackCUBE::getInstance();
             $user =& JFactory::getUser();
             $userTZ = $user->getParam('timezone', 0);
             $dateNow = new JDate();
             $dateNow->setOffset($userTZ);
             $cube->start(JText::_('DEFAULT_COMMENT') . ' ' . $dateNow->toFormat(JText::_('DATE_FORMAT_LC2'), ''));
             $cube->save();
             $this->setRedirect(JURI::base() . 'index.php?option=com_joomlapack&view=light&task=step&key=' . JRequest::getVar('key') . '&profile=' . JRequest::getInt('profile') . '&format=raw');
         }
     }
 }
开发者ID:albertobraschi,项目名称:Hab,代码行数:29,代码来源:light.php

示例2: authenticate

 /**
  * Tries to authenticate the user and start the backup, or send him back to the default task
  */
 public function authenticate()
 {
     // Enforce raw mode - I need to be in full control!
     $document =& JFactory::getDocument();
     $document->setType('raw');
     if (!$this->_checkPermissions()) {
         parent::redirect();
     } else {
         $session =& JFactory::getSession();
         $session->set('litemodeauthorized', 1, 'akeeba');
         $this->_setProfile();
         jimport('joomla.utilities.date');
         AECoreKettenrad::reset();
         $memory_filename = AEUtilTempvars::get_storage_filename(AKEEBA_BACKUP_ORIGIN);
         @unlink($memory_filename);
         $kettenrad =& AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN);
         $user =& JFactory::getUser();
         $userTZ = $user->getParam('timezone', 0);
         $dateNow = new JDate();
         $dateNow->setOffset($userTZ);
         if (AKEEBA_JVERSION == '16') {
             $description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->format(JText::_('DATE_FORMAT_LC2'), true);
         } else {
             $description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->toFormat(JText::_('DATE_FORMAT_LC2'));
         }
         $options = array('description' => $description, 'comment' => '');
         $kettenrad->setup($options);
         $ret = $kettenrad->tick();
         AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN);
         $this->setRedirect(JURI::base() . 'index.php?option=com_akeeba&view=light&task=step&key=' . urlencode(JRequest::getVar('key')) . '&profile=' . JRequest::getInt('profile') . '&format=raw');
     }
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:35,代码来源:light.php

示例3: build

 function build()
 {
     $formatedDate = "";
     if (!empty($this->dataValue) && $this->dataValue != "0000-00-00" && $this->dataValue != "00:00:00" && $this->dataValue != "0000-00-00 00:00:00") {
         jimport("joomla.utilities.date");
         $date = new JDate($this->dataValue);
         if ($tz = $this->timezone) {
             if ($tz == 'server') {
                 //TODO : Get the server timezone
                 $tz = 0;
                 //DBG
             } else {
                 if ($tz == 'local') {
                     //TODO : Get the current user local timezone
                     $tz = 0;
                     //DBG
                 }
             }
             $date->setOffset((int) $tz);
         }
         $formatedDate = $date->format($this->dateFormat, !empty($tz));
     }
     $this->addClass('fly-date');
     $html = '<span <%STYLE%><%CLASS%><%SELECTORS%>>' . $formatedDate . '</span>';
     return $html;
 }
开发者ID:gwtrains,项目名称:comRTiPrint,代码行数:26,代码来源:datetime.php

示例4: display

 /**
  * Starts a backup
  * @return 
  */
 function display()
 {
     // Check permissions
     $this->_checkPermissions();
     // Set the profile
     $this->_setProfile();
     // Force the output to be of the raw format type
     JRequest::setVar('format', 'raw');
     $document =& JFactory::getDocument();
     $document->setType('raw');
     // Get the description, if present; otherwise use the default description
     jimport('joomla.utilities.date');
     $user =& JFactory::getUser();
     $userTZ = $user->getParam('timezone', 0);
     $dateNow = new JDate();
     $dateNow->setOffset($userTZ);
     $default_description = JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->toFormat(JText::_('DATE_FORMAT_LC2'));
     $description = JRequest::getString('description', $default_description);
     // Start the backup (CUBE Operation)
     jpimport('core.cube');
     JoomlapackCUBE::reset();
     $cube =& JoomlapackCUBE::getInstance();
     $cube->start($description, '');
     $cube->save();
     // Return the JSON output
     parent::display(false);
 }
开发者ID:rlee1962,项目名称:diylegalcenter,代码行数:31,代码来源:json.php

示例5: display

 function display()
 {
     // Check permissions
     $this->_checkPermissions();
     // Set the profile
     $this->_setProfile();
     // Force the output to be of the raw format type
     JRequest::setVar('format', 'raw');
     $document =& JFactory::getDocument();
     $document->setType('raw');
     // Start the backup
     jimport('joomla.utilities.date');
     jpimport('core.cube');
     JoomlapackCUBE::reset();
     $cube =& JoomlapackCUBE::getInstance();
     $jconfig =& JFactory::getConfig();
     $userTZ = $jconfig->get('config.offset');
     /*
     $user =& JFactory::getUser();
     $userTZ = $user->getParam('timezone',0);
     */
     $dateNow = new JDate();
     $dateNow->setOffset($userTZ);
     $cube->start(JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->toFormat(JText::_('DATE_FORMAT_LC2'), ''));
     $cube->save();
     $this->setRedirect(JURI::base() . 'index.php?option=com_joomlapack&view=backup&task=step&key=' . JRequest::getVar('key') . '&profile=' . JRequest::getInt('profile', 1) . '&format=raw');
     parent::display();
 }
开发者ID:Ratmir15,项目名称:Joomla---formula-of-success,代码行数:28,代码来源:backup.php

示例6: display

	public function display()
	{
		// Check permissions
		$this->_checkPermissions();
		// Set the profile
		$this->_setProfile();

		// Start the backup
		jimport('joomla.utilities.date');
		AECoreKettenrad::reset();
		$memory_filename = AEUtilTempvars::get_storage_filename(AKEEBA_BACKUP_ORIGIN);
		@unlink($memory_filename);

		$kettenrad =& AECoreKettenrad::load(AKEEBA_BACKUP_ORIGIN);
		$user =& JFactory::getUser();
		$userTZ = $user->getParam('timezone',0);
		$dateNow = new JDate();
		$dateNow->setOffset($userTZ);
		if( AKEEBA_JVERSION == '16' ) {
			$description = JText::_('BACKUP_DEFAULT_DESCRIPTION').' '.$dateNow->format(JText::_('DATE_FORMAT_LC2'), true);
		} else {
			$description = JText::_('BACKUP_DEFAULT_DESCRIPTION').' '.$dateNow->toFormat(JText::_('DATE_FORMAT_LC2'));
		}
		$options = array(
			'description'	=> $description,
			'comment'		=> ''
		);
		$kettenrad->setup($options);
		$array = $kettenrad->tick();
		$array = $kettenrad->tick();
		AECoreKettenrad::save(AKEEBA_BACKUP_ORIGIN);
		
		if($array['Error'] != '')
		{
			// An error occured
			die('500 ERROR -- '.$array['Error']);
		}
		else
		{
			$noredirect = JRequest::getInt('noredirect', 0);
			if($noredirect != 0)
			{
				@ob_end_clean();
				echo "301 More work required";
				flush();
				JFactory::getApplication()->close();
			}
			else
			{
				$this->setRedirect(JURI::base().'index.php?option=com_akeeba&view=backup&task=step&key='.JRequest::getVar('key').'&profile='.JRequest::getInt('profile',1));
			}
		}
	}
开发者ID:rkern21,项目名称:videoeditor,代码行数:53,代码来源:backup.php

示例7: getDescription

 /**
  * Returns the backup description
  * 
  * @param bool $noDefault Set to true to avoid setting a default
  * @return string
  */
 function getDescription($noDefault = false)
 {
     $description = JRequest::getString('description');
     if (empty($description) && !$noDefault) {
         jimport('joomla.utilities.date');
         $user =& JFactory::getUser();
         $userTZ = $user->getParam('timezone', 0);
         $dateNow = new JDate();
         $dateNow->setOffset($userTZ);
         return JText::_('BACKUP_DEFAULT_DESCRIPTION') . ' ' . $dateNow->toFormat(JText::_('DATE_FORMAT_LC2'));
     }
     return $description;
 }
开发者ID:albertobraschi,项目名称:Hab,代码行数:19,代码来源:backup.php

示例8: getMonthEvent

 /**
  * Retturn list of all event that start with the given month/year
  */
 public function getMonthEvent($month, $year)
 {
     $db = JFactory::getDbo();
     // Filter event up to 24 hours earlier
     $date = new JDate();
     $date->setOffset(-24);
     // Select pending event and uncompleted milestone
     $where = '(	(' . $db->nameQuote('type') . '=' . $db->Quote('event') . ' AND ' . $db->nameQuote('start_date') . '>' . $db->Quote($date->toMySQL()) . ')' . ' OR ' . '(' . $db->nameQuote('type') . '=' . $db->Quote('milestone') . ' AND ' . $db->nameQuote('status') . '=' . $db->Quote('0') . ')' . ')';
     $where = $db->nameQuote('start_date') . '>= DATE(' . $db->Quote($year . '-' . $month . '-1') . ') ';
     $where .= ' AND ' . $db->nameQuote('start_date') . '<= DATE_ADD( DATE(' . $db->Quote($year . '-' . $month . '-1') . ') , INTERVAL 1 MONTH ) ';
     $where2 = $db->nameQuote('end_date') . '>= DATE(' . $db->Quote($year . '-' . $month . '-1') . ') ';
     $where2 .= ' AND ' . $db->nameQuote('end_date') . '<= DATE_ADD( DATE(' . $db->Quote($year . '-' . $month . '-1') . ') , INTERVAL 1 MONTH ) ';
     $where2 .= ' AND ' . $db->nameQuote('type') . '=' . $db->Quote('todo');
     $my = JXFactory::getUser();
     $userGroups = $my->getParam('groups_member');
     $where = '( ' . $where . ') AND (' . $db->nameQuote('access') . "=" . $db->Quote(0);
     if (!empty($userGroups)) {
         $where .= ' OR ' . $db->nameQuote('group_id') . 'IN (' . $userGroups . ') )';
     } else {
         $where .= ')';
     }
     $where2 = '( ' . $where2 . ') AND (' . $db->nameQuote('access') . "=" . $db->Quote(0);
     if (!empty($userGroups)) {
         $where2 .= ' OR ' . $db->nameQuote('group_id') . 'IN (' . $userGroups . ') )';
     } else {
         $where2 .= ')';
     }
     $query = 'SELECT * FROM #__stream WHERE ' . $where . ' UNION SELECT * FROM #__stream WHERE ' . $where2 . ' ORDER BY ' . $db->nameQuote('start_date') . ' ASC';
     $db->setQuery($query);
     $result = $db->loadObjectList();
     $rows = array();
     if (!empty($result)) {
         foreach ($result as $row) {
             $obj = JTable::getInstance('Stream', 'StreamTable');
             $obj->bind($row);
             $rows[] = $obj;
         }
     }
     return $rows;
 }
开发者ID:ErickLopez76,项目名称:offiria,代码行数:43,代码来源:events.php

示例9: getDateRangeByViewType

 function getDateRangeByViewType($date = null, $viewType = 'month')
 {
     global $now;
     $viewType = $viewType == '' ? 'month' : $viewType;
     if ($date == null) {
         $date = $now;
     } else {
         $arr = explode("/", $date);
         $date = $arr[2] . "-" . $arr[0] . "-" . $arr[1];
         $date = new JDate($date);
     }
     switch ($viewType) {
         case 'month':
             $startoffset = -($arr[1] + 5);
             $date->setOffset($startoffset * 24);
             $startdate = $date->toFormat('%Y-%m-%d');
             $endoffest = 35 - $arr[1];
             $date->setOffset($endoffest * 24);
             $enddate = $date->toFormat('%Y-%m-%d');
             break;
         case 'week':
             $startoffset = -7;
             $date->setOffset($startoffset * 24);
             $startdate = $date->toFormat('%Y-%m-%d');
             $endoffest = 7;
             $date->setOffset($endoffest * 24);
             $enddate = $date->toFormat('%Y-%m-%d');
             break;
         case 'day':
             $startoffset = -1;
             $date->setOffset($startoffset * 24);
             $startdate = $date->toFormat('%Y-%m-%d');
             $endoffest = 1;
             $date->setOffset($endoffest * 24);
             $enddate = $date->toFormat('%Y-%m-%d');
             break;
     }
     return array('startdate' => $startdate, 'enddate' => $enddate);
 }
开发者ID:reeleis,项目名称:ohiocitycycles,代码行数:39,代码来源:dtcommon.php

示例10: JDate

		case 'fail':
			$status = JText::_('STATS_LABEL_STATUS_FAIL');
			break;

		case 'pending':
			$status = JText::_('STATS_LABEL_STATUS_PENDING');
			break;
	}

	jimport('joomla.utilities.date');
	$startTime = new JDate($record['backupstart']);
	$endTime = new JDate($record['backupend']);

	$user =& JFactory::getUser();
	$userTZ = $user->getParam('timezone',0);
	$startTime->setOffset($userTZ);

	$filename_col = '';

	if(empty($record['description'])) $record['description'] = JText::_('STATS_LABEL_NODESCRIPTION');
	?>
		<tr class="row<?php echo $id; ?>">
			<td><?php echo $check; ?></td>
			<td>
				<?php echo $this->escape($record['description']) ?>
			</td>
			<td>
				<?php if( AKEEBA_JVERSION == '16' ): ?>
					<?php echo $startTime->format(JText::_('DATE_FORMAT_LC2'), true); ?>
				<?php else: ?>
					<?php echo $startTime->toFormat(JText::_('DATE_FORMAT_LC2')); ?>
开发者ID:rkern21,项目名称:videoeditor,代码行数:31,代码来源:restorepoint.php

示例11: showList


//.........这里部分代码省略.........
						<?php 
        echo JHTML::_('grid.sort', 'Section', 'sect_name', @$lists['order_Dir'], @$lists['order']);
        ?>
					</th>
					<th width="10%" class="title">
						<?php 
        echo JHTML::_('grid.sort', 'Category', 'cc.name', @$lists['order_Dir'], @$lists['order']);
        ?>
					</th>
					<th width="10%" class="title">
						<?php 
        echo JHTML::_('grid.sort', 'Author', 'author', @$lists['order_Dir'], @$lists['order']);
        ?>
					</th>
				</tr>
			</thead>
			<tfoot>
			<tr>
				<td colspan="13">
					<?php 
        echo $page->getListFooter();
        ?>
				</td>
			</tr>
			</tfoot>
			<tbody>
			<?php 
        $k = 0;
        for ($i = 0, $n = count($rows); $i < $n; $i++) {
            $row =& $rows[$i];
            $link = JRoute::_('index.php?option=com_content&task=edit&cid[]=' . $row->id);
            $publish_up = new JDate($row->publish_up);
            $publish_down = new JDate($row->publish_down);
            $publish_up->setOffset($config->getValue('config.offset'));
            $publish_down->setOffset($config->getValue('config.offset'));
            if ($now->toUnix() <= $publish_up->toUnix() && $row->state == 1) {
                $img = 'publish_y.png';
                $alt = JText::_('Published');
            } else {
                if (($now->toUnix() <= $publish_down->toUnix() || $row->publish_down == $nullDate) && $row->state == 1) {
                    $img = 'publish_g.png';
                    $alt = JText::_('Published');
                } else {
                    if ($now->toUnix() > $publish_down->toUnix() && $row->state == 1) {
                        $img = 'publish_r.png';
                        $alt = JText::_('Expired');
                    } else {
                        if ($row->state == 0) {
                            $img = 'publish_x.png';
                            $alt = JText::_('Unpublished');
                        } else {
                            if ($row->state == -1) {
                                $img = 'disabled.png';
                                $alt = JText::_('Archived');
                            }
                        }
                    }
                }
            }
            $times = '';
            if (isset($row->publish_up)) {
                if ($row->publish_up == $nullDate) {
                    $times .= JText::_('Start: Always');
                } else {
                    $times .= JText::_('Start') . ": " . $publish_up->toFormat();
                }
开发者ID:Fellah,项目名称:govnobaki,代码行数:67,代码来源:frontpage.php

示例12: getBackupState

	/**
	 * Returns the backup state ('none','start', or 'step')
	 */
	private function getBackupState()
	{
		$this->debugInfo = '<h6>Akeeba Backup Lazy Mode</h6><hr/>';
		// Make sure we're not locked
		if($this->isLocked()) {
			$this->debugInfo .= 'Backup locked';
			// If the backup has crashed, clean up
			if($this->isCrashed)
			{
				$this->debugInfo .= 'Crashed backup detected';
				AEFactory::nuke();
				AEUtilTempvars::reset('lazy');
				$this->unsetNonce();
				$this->unsetLock();
				$this->saveStorage();
			}
			else
			{
				return 'none';
			}
		}

		// Is there a backup running?
		$this->getNonce();

		$action = empty($this->nonce) ? 'start' : 'step';
		$this->debugInfo .= '<br/>Action: '.$action;

		// If there is no running backup, try to figure out if we should start
		// a new backup.
		if($action == 'start')
		{
			// Get the last backup time
			$lastBackup = $this->getLastBackupTime();
			$this->debugInfo .= '<br/>Last backup: '.$lastBackup.' ('.date('Y/m/d H:i:s',$lastBackup).' GMT)';

			// Remove the time part of the backup time (we want the date starting at midnight!)
			$deconstructedDate = getdate($lastBackup);
			$lastBackup = mktime( 0,0,0, $deconstructedDate['mon'], $deconstructedDate['mday'], $deconstructedDate['year'] );
			$this->debugInfo .= '<br/>Adjusted last backup time: '.$lastBackup.' ('.date('Y/m/d H:i:s',$lastBackup).' GMT)';

			// Get the preferences and calculate the next backup time
			$daysfreq = (int)$this->params->get('daysfreq',1);
			if($daysfreq <= 0) $daysfreq = 1;
			$this->debugInfo .= '<br/>Days frequency: '.$daysfreq;
			$daysfreq *= 86400;
			$backuptime = $this->params->get('backuptime','00:00');
			$this->debugInfo .= '<br/>Backup time: '.$backuptime;

			$backuptime = trim($backuptime);
			$parts = explode(':',$backuptime);
			if(count($parts) != 2) {
				$backuptime = 0;
			} else {
				$hours = (int)$parts[0];
				$mins = (int)$parts[1];
				$backuptime = $hours * 3600 + $mins * 60;
			}
			$this->debugInfo .= ' ('.$backuptime.' seconds)';
			$nextBackup = $lastBackup + $daysfreq + $backuptime;
			$this->debugInfo .= '<br/>Next Backup: '.$nextBackup.' ('.date('Y/m/d H:i:s',$nextBackup).' GMT)';

			// The next backup time is in GMT. Convert to local.
			jimport('joomla.utilities.date');
			$date = new JDate($nextBackup, 0);
			$jreg = JFactory::getConfig();
			$offset = $jreg->getValue('config.offset');
			$date->setOffset($offset);
			$nextBackup = $date->toUnix(true);

			$this->debugInfo .= '<br/>Next Backup: '.$nextBackup.' ('.date('Y/m/d H:i:s',$nextBackup).' LOCAL)';
			$this->debugInfo .= '<br/>Time Now: '.time().' ('.date('Y/m/d H:i:s').' LOCAL)';

			// Is it time for the next backup to run?
			if( time() < $nextBackup ) {
				$this->debugInfo .= '<br/>I will not start a new backup.';
			} else {
				$this->debugInfo .= '<br/><strong>Starting new backup.</strong>';
			}
			if( time() < $nextBackup ) return 'none';

			// Create a new nonce
			$this->setNonce();
			$this->saveStorage();
		}

		return $action;
	}
开发者ID:srbsnkr,项目名称:sellingonlinemadesimple,代码行数:91,代码来源:main.php

示例13: getExpandedTarName

 /**
  * Expands the archive's template name and returns an absolute path
  *
  * @param string $extension The extension to append, defaults to '.zip'
  * @return string The absolute filename of the archive file requested
  * @static
  */
 function getExpandedTarName($extension = '.zip', $fullPath = true)
 {
     $configuration =& JoomlapackModelRegistry::getInstance();
     // Get the proper extension
     $templateName = $configuration->get('TarNameTemplate');
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Archive template name: {$templateName}");
     // Get current date/time and express it in user's timezone
     jimport('joomla.utilities.date');
     $user =& JFactory::getUser();
     $userTZ = $user->getParam('timezone', 0);
     $dateNow = new JDate();
     $dateNow->setOffset($userTZ);
     // Parse [DATE] tag
     $dateExpanded = $dateNow->toFormat("%Y%m%d");
     $templateName = str_replace("[DATE]", $dateExpanded, $templateName);
     // Parse [TIME] tag
     $timeExpanded = $dateNow->toFormat("%H%M%S");
     $templateName = str_replace("[TIME]", $timeExpanded, $templateName);
     // Parse [HOST] tag
     $uri =& JURI::getInstance();
     $host = $uri->getHost();
     $host = empty($host) ? 'unknown_host' : $uri->getHost();
     $templateName = str_replace("[HOST]", $_SERVER['SERVER_NAME'], $templateName);
     // Parse [RANDOM] tag
     $templateName = str_replace("[RANDOM]", md5(microtime()), $templateName);
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Expanded template name: {$templateName}");
     if ($fullPath) {
         $path = $configuration->get('OutputDirectory') . DS . $templateName . $extension;
         JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Calculated archive absolute path: {$path}");
         return JoomlapackHelperUtils::TranslateWinPath($path);
     } else {
         return $templateName . $extension;
     }
 }
开发者ID:BackupTheBerlios,项目名称:kmit-svn,代码行数:41,代码来源:utils.php

示例14: getLocaleDate

 /**
  * Return locale date
  *
  * @param	null
  * @return	date object
  * @since   2.4.2
  **/
 function getLocaleDate($date = 'now')
 {
     $mainframe =& JFactory::getApplication();
     if (method_exists('JDate', 'getOffsetFromGMT')) {
         // Joomla 1.6
         $systemOffset = new CDate('now', $mainframe->getCfg('offset'));
         $systemOffset = $systemOffset->getOffsetFromGMT(true);
     } else {
         $systemOffset = $mainframe->getCfg('offset');
         // Joomla 1.5
     }
     $now = new JDate($date, $systemOffset);
     // // Joomla 1.6
     $now->setOffset($systemOffset);
     // // Joomla 1.5
     return $now;
 }
开发者ID:Simarpreet05,项目名称:joomla,代码行数:24,代码来源:time.php

示例15: getRelativeDate

 public static function getRelativeDate($value, $countParts = 1)
 {
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $tz = new DateTimeZone(JFactory::getApplication()->getCfg('offset'));
         $now = JFactory::getDate();
         $now->setTimeZone($tz);
     } else {
         $offset = JFactory::getConfig()->getValue('config.offset');
         $now = new JDate();
         $now->setOffset($offset);
     }
     $date = new JDate($value);
     $diff = $now->toUnix() - $date->toUnix();
     $result = $value;
     $timeParts = array(31536000 => 'MOD_JCOMMENTS_LATEST_RELATIVE_DATE_YEARS', 2592000 => 'MOD_JCOMMENTS_LATEST_RELATIVE_DATE_MONTHS', 604800 => 'MOD_JCOMMENTS_LATEST_RELATIVE_DATE_WEEKS', 86400 => 'MOD_JCOMMENTS_LATEST_RELATIVE_DATE_DAYS', 3600 => 'MOD_JCOMMENTS_LATEST_RELATIVE_DATE_HOURS', 60 => 'MOD_JCOMMENTS_LATEST_RELATIVE_DATE_MINUTES', 1 => 'MOD_JCOMMENTS_LATEST_RELATIVE_DATE_SECONDS');
     if ($diff < 5) {
         $result = JText::_('MOD_JCOMMENTS_LATEST_RELATIVE_DATE_NOW');
     } else {
         $dayDiff = floor($diff / 86400);
         $nowDay = date('d', $now->toUnix());
         $dateDay = date('d', $date->toUnix());
         if ($dayDiff == 1 || $dayDiff == 0 && $nowDay != $dateDay) {
             $result = JText::_('MOD_JCOMMENTS_LATEST_RELATIVE_DATE_YESTERDAY');
         } else {
             $count = 0;
             $resultParts = array();
             foreach ($timeParts as $key => $value) {
                 if ($diff >= $key) {
                     $time = floor($diff / $key);
                     $resultParts[] = modJCommentsLatestHelper::getPluralText($value, $time);
                     $diff = $diff % $key;
                     $count++;
                     if ($count > $countParts - 1 || $diff == 0) {
                         break;
                     }
                 }
             }
             if (count($resultParts)) {
                 $result = JText::sprintf('MOD_JCOMMENTS_LATEST_RELATIVE_DATE_AGO', implode(', ', $resultParts));
             }
         }
     }
     return $result;
 }
开发者ID:enjoy2000,项目名称:smcd,代码行数:44,代码来源:helper.php


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