public function timeElapsed($datetime, $full = false) { $now = JFactory::getDate(); $ago = JFactory::getDate($datetime); $diff = $now->diff($ago); $diff->w = floor($diff->d / 7); $diff->d -= $diff->w * 7; $string = array( 'y' => 'YEAR', 'm' => 'MONTH', 'w' => 'WEEK', 'd' => 'DAY', 'h' => 'HOUR', 'i' => 'MINUTE', 's' => 'SECOND', ); foreach ($string as $k => &$v) { if ($diff->$k) { $v = $diff->$k . ' ' . JText::_( $v . ($diff->$k > 1 ? 'S' : '')); } else { unset($string[$k]); } } if (!$full) { $string = array_slice($string, 0, 1); } return $string ? implode(', ', $string) .' ' . JText::_('AGO') : JText::_('JUST_NOW'); }
AGO="fa" JUST_NOW="Adesso" YEAR="anno" MONTH="mese" WEEK="settimana" DAY="giorno" HOUR="ora" MINUTE="minuto" SECOND="secondo" YEARS="anni" MONTHS="mesi" WEEKS="settimane" DAYS="giorni" HOURS="ore" MINUTES="minuti" SECONDS="secondi"
Please Log in or Create an account to join the conversation.