Days from being published

17 views
Skip to first unread message

Fred Durst

unread,
Jun 28, 2016, 6:50:23 PM6/28/16
to Joomla! General Development
I wrote a code that shows days from publish date of a article.

But that doesn't work on all templates.

Maybe you will help me change it to work everywhere.


{source}

<?php
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
if ($option=="com_content" && $view=="article") {
$ids = explode(':',JRequest::getString('id'));
$article_id = $ids[0];
$article =& JTable::getInstance("content");
$article->load($article_id);
$date = new JDate($article->get("publish_up"));

$currentTime = new JDate('now');

$interval = $date->diff($currentTime);

if($interval->d == 0) {
echo 'dzisiaj' . "<br>";
}
else if( $interval->d == 1) {
echo 'wczoraj' . "<br>";
}
else if( $interval->d > 1) {
echo $interval->format('%a dni temu') . "<br>";
}


}

?>

{/source}


here is the code I use. Please help.

Allon Moritz

unread,
Jun 29, 2016, 1:34:01 AM6/29/16
to joomla-de...@googlegroups.com
Where did you put that code?


--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To post to this group, send an email to joomla-de...@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages