function showDate($time, $mode = 'datetime_today', $tz = 'kunena', $offset = null)
 {
     $app =& JFactory::getApplication();
     $kunena_config = KunenaFactory::getConfig();
     $date = JFactory::getDate($time);
     if ($offset === null || strtolower($tz) != 'utc') {
         $offset = JFactory::getUser()->getParam('timezone', $app->getCfg('offset', 0));
     }
     if (is_numeric($offset)) {
         $date->setOffset($offset);
     } else {
         // Joomla 1.6 support
         $offset = new DateTimeZone($offset);
         $date->setTimezone($offset);
     }
     if ($date->toFormat('%Y') < 1902) {
         return JText::_('COM_KUNENA_DT_DATETIME_UNKNOWN');
     }
     if (preg_match('/^config_/', $mode) == 1) {
         $option = substr($mode, 7);
         $mode = $kunena_config->{$option};
     }
     $modearr = explode('_', $mode);
     switch (strtolower($modearr[0])) {
         case 'none':
             return '';
         case 'time':
             $usertime_format = JText::_('COM_KUNENA_DT_TIME_FMT');
             $today_format = JText::_('COM_KUNENA_DT_TIME_FMT');
             $yesterday_format = JText::_('COM_KUNENA_DT_TIME_FMT');
             break;
         case 'date':
             $usertime_format = JText::_('COM_KUNENA_DT_DATE_FMT');
             $today_format = JText::_('COM_KUNENA_DT_DATE_TODAY_FMT');
             $yesterday_format = JText::_('COM_KUNENA_DT_DATE_YESTERDAY_FMT');
             break;
         case 'ago':
             return CKunenaTimeformat::showTimeSince($date->toUnix());
             break;
         case 'datetime':
             $usertime_format = JText::_('COM_KUNENA_DT_DATETIME_FMT');
             $today_format = JText::_('COM_KUNENA_DT_DATETIME_TODAY_FMT');
             $yesterday_format = JText::_('COM_KUNENA_DT_DATETIME_YESTERDAY_FMT');
             break;
         default:
             $usertime_format = $mode;
             $today_format = $mode;
             $yesterday_format = $mode;
     }
     // Today and Yesterday?
     if ($modearr[count($modearr) - 1] == 'today') {
         $now = JFactory::getDate('now');
         $now = @getdate($now->toUnix());
         $then = @getdate($date->toUnix());
         // Same day of the year, same year.... Today!
         if ($then['yday'] == $now['yday'] && $then['year'] == $now['year']) {
             $usertime_format = $today_format;
         }
         // Day-of-year is one less and same year, or it's the first of the year and that's the last of the year...
         if ($then['yday'] == $now['yday'] - 1 && $then['year'] == $now['year'] || $now['yday'] == 0 && $then['year'] == $now['year'] - 1 && $then['mon'] == 12 && $then['mday'] == 31) {
             $usertime_format = $yesterday_format;
         }
     }
     return $date->toFormat($usertime_format, true);
 }