Issue: Modified Date is Showing Current Date? Topic is solved

General questions relating to Joomla! 4.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
gaussian
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Tue Sep 22, 2020 9:59 pm

Issue: Modified Date is Showing Current Date?

Post by gaussian » Tue Oct 03, 2023 2:12 pm

After a recent Joomla update, the dateModified code now displays the current date rather than the article's modified date. Example code below, which is showing today's date rather than date modified.

In 13 years of using Joomla, I've never seen this issue!

Anyone else seeing it happen?

Code: Select all

<time datetime="<?php echo HTMLHelper::_('date', $displayData['item']->modified, 'c'); ?>" itemprop="dateModified">
<?php echo Text::sprintf('COM_CONTENT_LAST_UPDATED', HTMLHelper::_('date', $displayData['item']->modified, Text::_('DATE_FORMAT_LC3'))); ?>
</time>

gaussian
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Tue Sep 22, 2020 9:59 pm

Re: Issue: Modified Date is Showing Current Date?

Post by gaussian » Thu Oct 05, 2023 4:03 pm

Does anyone have ideas on how to troubleshoot or fix this issue?

:'(

User avatar
ceford
Joomla! Hero
Joomla! Hero
Posts: 2284
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: Issue: Modified Date is Showing Current Date?

Post by ceford » Fri Oct 06, 2023 4:12 am

I can't reproduce your problem. Copied from Article Details:

Code: Select all

    Published: 06 October 2023 
    Created: 04 October 2023 
    Last Updated: 05 October 2023 
Can you open your #__content table with phpMyAdmin and see what the actual dates are for a specific item?

gaussian
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Tue Sep 22, 2020 9:59 pm

Re: Issue: Modified Date is Showing Current Date?

Post by gaussian » Sat Oct 14, 2023 2:20 pm

ceford wrote:
Fri Oct 06, 2023 4:12 am
I can't reproduce your problem. Copied from Article Details:

Code: Select all

    Published: 06 October 2023 
    Created: 04 October 2023 
    Last Updated: 05 October 2023 
Can you open your #__content table with phpMyAdmin and see what the actual dates are for a specific item?
Hi - thanks for the reply! I think you can't reproduce because we use Cloudflare CDN, which is caching an earlier date. But if we clear that cache, it shows the current date.

I looked in the content table and it shows the true modified date (even after clearing cache and reloading the page). So there is something about the code (above) I'm using to pull modified date that is suddenly (since the most recent update) working incorrectly and showing the current date.

Any possible fix that you can think of? Or troubleshooting for the code?

User avatar
ceford
Joomla! Hero
Joomla! Hero
Posts: 2284
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: Issue: Modified Date is Showing Current Date?

Post by ceford » Sat Oct 14, 2023 6:30 pm

I pasted your code into a template override at cassiopeia/html/com_content/article/default.php and it does inded display the current date and time. The reason is that $displayData is NULL so the HTMHelper call returns the current date and time. With the following I get the correct modified data:

Code: Select all

<time datetime="<?php echo HTMLHelper::_('date', $this->item->modified, 'c'); ?>" itemprop="dateModified">
<?php echo Text::sprintf('COM_CONTENT_LAST_UPDATED', HTMLHelper::_('date', $this->item->modified, Text::_('DATE_FORMAT_LC3'))); ?>
</time>

gaussian
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Tue Sep 22, 2020 9:59 pm

Re: Issue: Modified Date is Showing Current Date?

Post by gaussian » Sat Oct 14, 2023 7:51 pm

ceford wrote:
Sat Oct 14, 2023 6:30 pm
I pasted your code into a template override at cassiopeia/html/com_content/article/default.php and it does inded display the current date and time. The reason is that $displayData is NULL so the HTMHelper call returns the current date and time. With the following I get the correct modified data:

Code: Select all

<time datetime="<?php echo HTMLHelper::_('date', $this->item->modified, 'c'); ?>" itemprop="dateModified">
<?php echo Text::sprintf('COM_CONTENT_LAST_UPDATED', HTMLHelper::_('date', $this->item->modified, Text::_('DATE_FORMAT_LC3'))); ?>
</time>
Thank you for helping! Sourcerer doesn't like the use of '$this' but it seems to work otherwise.

:D

gaussian
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Tue Sep 22, 2020 9:59 pm

Re: Issue: Modified Date is Showing Current Date?

Post by gaussian » Tue Oct 17, 2023 4:00 pm

For those looking to do something similar to this (embed article modified date in a module so you can customize its look/feel), I suggest using the Articles Anywhere plugin.


Post Reply

Return to “General Questions/New to Joomla! 4.x”