Home / Joomla Hacks / Joomla Websites Always Showing Today's Date 
Joomla Hacks
Feb
02
2010
Joomla Websites Always Showing Today's Date
Written by Steve Burge   
Avatar

Here's a little fix we came across today while trying to find out why blog posts on this site had started always showing today's date. Even if a post was written in 2006 or 2007 it would show a 2010 date. Thanks to Anthony from Joomla Bamboo for helping me find the fix.

The problem is with overrides and you're likely to find them in this folder: / templates / your-template-name / html / com_content / article / default.php

The correct date line is going to look similar to this:

<?php echo JHTML::_('date', $this->article->created, JText::_('<div class="month">%b</div><div class="day">%d</div>%Y')); ?>

I've highlighted the two elements that need changing: JText::_( before the opening div and an extra ) at the end. The original line is likely to be found in templates that were created around Joomla 1.5.13 and earlier. It's more likely to look like this:

<?php echo JHTML::_('date', $this->article->created, '<div class="month">%b</div><div class="day">%d</div>%Y'); ?>

Because commercial and custom templates often don't get updated along with the Joomla core, errors like this can remain on a site.

And yes, this post was really written in 2010.

 

Comments  

 
#1 bradon 2010-02-03 01:06
good explanation..
Quote
 
 
#2 Edvard Ananyan 2010-02-04 05:48
Not sure if you have already fixed it, but for me it is still today for all your posts on your your http://www.alledia.com/blog/
Quote
 
 
#3 Steve Burge 2010-02-04 06:18
Ooops - thanks Edvard

I need to the fix the blog section override file too.
Quote
 
 
#4 Rodel 2010-02-04 18:11
nice one!8)
Quote
 
 
#5 rodeldesign 2010-02-04 18:14
Nice information. By the way, joomla bamboo rocks for many reasons. This is a new one!
Quote
 
 
#6 TooN 2010-03-10 10:10
Im not sure if this topic is related to it but i want to have the date next to the titles at the read more section. Just like showing here below....

can someone help me with this? will this be a core hack?

Thanks
Quote
 
 
#7 Alex Podgornyi 2010-04-12 23:45
I have the following code:

echo JHTML::_('date', $item->modified, JText::_('DATE_FORMAT_LC3'));

That works on one site correctly, displaying 'creation date' and on the other site is shows todays date.

Cant figure out what's wrong with it. Any ideas???
Quote
 

Add comment


Security code
Refresh