Joomla Websites Always Showing Today’s Date

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.

Leave a Reply

Your email address will not be published. Required fields are marked *