K2 items time not showing in frontend

April 2013 Joomla Templates
Rate this topic: Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.1.00 out of 6 based on 1 vote(s)
GK User
Tue Aug 12, 2014 7:26 pm
Reply with quote
Report this post
Hello. I am trying to figure out how can i display K2 item publish time in frontend. In backend i see the time as expected but not in frontend. I saw that the template in your demo page has only the date in k2 articles

http://demo.gavick.com/joomla25/rockwal ... premiereft.
Is there a way to display time too next to the date? Thanks in advance.
User avatar
Junior Boarder

teitbite
Thu Aug 14, 2014 6:18 pm
Reply with quote
Report this post
Hi

Please edit file /html/com_k2/default/item.php and find line 38 which should looks like:

Code: Select all
                  <time datetime="<?php echo JHtml::_('date', $this->item->created, JText::_(DATE_W3C)); ?>"> <?php echo JHTML::_('date', $this->item->created, JText::_('F j, Y')); ?> </time>


change it to:

Code: Select all
                  <time datetime="<?php echo JHtml::_('date', $this->item->created, JText::_(DATE_W3C)); ?>"> <?php echo JHTML::_('date', $this->item->created, JText::_('F j, Y h:i')); ?> </time>

User avatar
Moderator

GK User
Sun Aug 17, 2014 1:17 pm
Reply with quote
Report this post
Thank you teitbite once again for your fast and accurate response. Worked like a charm. But is there a way to show 24-hour time? For example in here http://www.unboxholics.com/news/gaming/ ... sakh-karpa

I want to show 16:30 instead of 04:30.
User avatar
Junior Boarder

GK User
Mon Aug 18, 2014 8:56 am
Reply with quote
Report this post
Never mind. I found it. I just changed h to H in this line
Code: Select all
JText::_('F j, Y h:i'))
and that did the trick ;)
User avatar
Junior Boarder

teitbite
Tue Aug 19, 2014 11:41 am
Reply with quote
Report this post
Hi

Here is a full list of possible arguments: http://php.net/manual/pl/function.date.php
User avatar
Moderator


cron
Remember me
Register New Account
If you are old Gavick user, click HERE for steps to retrieve your account.