Keyword

Dates not displaying correctly after update to Joomla 3.8.13 and K2 2.9.

  • Andrew Paterson
  • Andrew Paterson's Avatar Topic Author
  • Offline
  • Junior Member
More
6 years 1 month ago #169628 by Andrew Paterson
After updating Joomla to 3.8.13, the dates in all K2 content modules, K2 category items and K2 items are not being formatted correctly.

K2 version is and K2 2.9.

They look like this: %AM, %14 %315 %2018. where they have been working fine before.

This is the template code I'm using for mod_content for example:
<?php if($params->get('itemDateCreated')): ?>
        <span class="moduleItemDateCreated"> <?php echo JHTML::_('date', $item->created, JText::_('K2_DATE_FORMAT_LC')); ?></span>
      <?php endif; ?>

This is in my current en-GB.com_k2.ini file:
K2_DATE_FORMAT="%d/%m/%Y - %H:%M"
K2_DATE_FORMAT_LC2="%A, %d %B %Y %H:%M"
K2_DATE_FORMAT_LC="%A, %d %B %Y"

The problem occurs whent he PHP version is either 5.6 or 7.0.

Please Log in or Create an account to join the conversation.

More
6 years 1 month ago #169643 by JoomlaWorks
mod_k2_content loads its own language file from /language/en-GB/en-GB.mod_k2_content.ini - make sure nothing else is overriding K2's language strings for date definitions (it could be an override placed in the Joomla backend for example).

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Andrew Paterson
  • Andrew Paterson's Avatar Topic Author
  • Offline
  • Junior Member
More
6 years 1 month ago #169677 by Andrew Paterson
Thank you.

The formatting issue is happening with all K2 templates- category list items, full items and items in the K2 content module. I tried pasting the date format string directly into the template as below.
<span class="catItemDateCreated"> <?php echo JHTML::_('date', $this->item->publish_up , "%A, %d %B %Y %H:%M"); ?> </span>

The date looks like this on the frontend:

%AM, %26 %343 %2016 %09:%Sep

I tried with the default K2 date format:
<span class="catItemDateCreated"> <?php echo JHTML::_('date', $this->item->publish_up , "%d/%m/%Y - %H:%M"); ?> </span>

The date appears like this:

%26/%09/%2016 - %09:%Sep

If I remove the date format altogether, I get what I assume is the default Joomla date format.
<span class="catItemDateCreated"> <?php echo JHTML::_('date', $this->item->publish_up); ?> </span>

Monday, 26 September 2016

Do you think the above could still be caused by an override of a K2 language file?

Please Log in or Create an account to join the conversation.

More
6 years 1 month ago #169686 by JoomlaWorks
I literally have no idea. It's the first time anyone reports something like that. It could be a broken override or even a system plugin.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
6 years 1 month ago #169790 by Florian
Hi All,
Just to mention I'm facing the same issue. It occurs on frontend but not on backend where I can see date displaying correctly.
Joomla 3.8.13 / PHP 7.2

Please Log in or Create an account to join the conversation.

More
6 years 1 month ago #169796 by JoomlaWorks
@Andrew
Change the code to:
<span class="catItemDateCreated">
    <?php echo JHTML::_('date', $this->item->publish_up , "d/m/Y - H:i"); ?>
</span>

In other words don't use % and refer to php.net/manual/en/function.date.php for date formatting.

@Florian
Can you try the above solution as well and let me know if it works please?

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
6 years 1 month ago - 6 years 1 month ago #169805 by Florian
Hi Fotis,

Thanks for your support. I've made the change and it is working fine.
For your information, the original code was :
<span class="itemDateCreated"> <?php echo JHTML::_('date', $this->item->created, JText::_('K2_DATE_FORMAT_LC2')); ?>

Any clue why it stops displaying correctly ?

Update: i'm using french language file (fr-FR.com_k2.ini version 2.7.x) and variable K2_DATE_FORMAT_LC2 has value "%A, %d %B %Y %H:%M".
Last edit: 6 years 1 month ago by Florian. Reason: add details

Please Log in or Create an account to join the conversation.

More
6 years 1 month ago #169814 by JoomlaWorks
I couldn't replicate the issue. Did you also check that there is no direct override from the language overrides section in Joomla's backend?

Out of curiosity, what PHP version are you using?

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Andrew Paterson
  • Andrew Paterson's Avatar Topic Author
  • Offline
  • Junior Member
More
6 years 1 month ago #169817 by Andrew Paterson
Thank you, this works for me.
I really appreciate your help.

Please Log in or Create an account to join the conversation.

More
6 years 1 month ago #169818 by JoomlaWorks
Good to know Andrew.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum