One of our Spanish-speaking customers needed to hide the hour and minutes displayed by K2 items.
By default, Joomla content doesn't display the time. So the customer wanted their K2 dates to match the normal Joomla articles on their site.
In this tutorial, you will learn to use a language override to achieve this.
The image below shows the default view for K2 items in Spanish:
This next image shows the dates of K2 individual items:
Our customer wanted their dates without the hour and minutes:
The date format is set by this line:
K2_DATE_FORMAT_LC2="l, d F Y H:i"
You'll find this language string in the /administrator/language/es-ES/es-ES.com_k2.dates.ini file.
Yes, you can edit this string and change it from
K2_DATE_FORMAT_LC2="l, d F Y H:i" to
K2_DATE_FORMAT_LC2="l, d F Y".
However, editing the file in not an ideal solution. Joomla constantly updates. International language packages get updated as well. If you apply the date fix editing the /administrator/language/es-ES/es-ES.com_k2.dates.ini file directly, you will lose it next time you install a newly released K2 language pack. There is a way to avoid this future problem.
- In your Joomla backend, go to Extensions > Language(s) > Overrides:
- You will be taken to the Languages: Overrides administrative page.
- Click New:
- Next, switch the Search For box from Value to Constant:
- Enter K2_DATE_FORMAT_LC2 into the Search box.
- Click Search:
- Click on the first search result.
- You will see the date formatting code of
%A, %d %B %Y %H:%Mappeared inside the Text box:
- Replace the
%A, %d %B %Y %H:%Mcode with the
l, d F Y.
- Click Save & Close:
- You will see your new language override listed:
There you have it. If you check how your K2 content gets displayed on your site front end, you will notice that the hour and minutes don't get displayed now.