Source for file date.php
Documentation is available at date.php
* @package Joomla.Libraries
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* Extended Utility class for handling date display.
* @package Joomla.Libraries
* Function to convert a static time into a relative measurement
* @param string $date The date to convert
* @param string $unit The optional unit of measurement to return
* if the value of the diff is greater than one
* @param string $time An optional time to compare to, defaults to now
* @return string The converted time string
public static function relative($date, $unit =
null, $time =
null)
// Get the difference in seconds between now and the time
return JText::_('JLIB_HTML_DATE_RELATIVE_LESSTHANAMINUTE');
$diff =
round($diff /
60);
if ($diff <
60 ||
$unit ==
'minute')
return JText::plural('JLIB_HTML_DATE_RELATIVE_MINUTES', $diff);
$diff =
round($diff /
60);
if ($diff <
24 ||
$unit ==
'hour')
return JText::plural('JLIB_HTML_DATE_RELATIVE_HOURS', $diff);
$diff =
round($diff /
24);
if ($diff <
7 ||
$unit ==
'day')
return JText::plural('JLIB_HTML_DATE_RELATIVE_DAYS', $diff);
$diff =
round($diff /
7);
if ($diff <=
4 ||
$unit ==
'week')
return JText::plural('JLIB_HTML_DATE_RELATIVE_WEEKS', $diff);
// Over a month, return the absolute time
return JHtml::_('date', $date);
Documentation generated on Tue, 19 Nov 2013 14:57:56 +0100 by phpDocumentor 1.4.3