Joomla! Localized Date Format
When working on a Joomla website, which is using the Urdu language package, I was trying to show the current date in Urdu on the top of the website header too. However, looks like finding the correct format string to convert the date to Urdu (or current language) was bit more tricky than I thought.I tried to find this in the Joomla support forums and documentation, but may be I was not using the correct search term, so didn’t found the relevant example.
After the search failure, I decided to explore the theme files to get idea on how this is done on the Article page, and I found the answer by looking at the article theme file at:
Joomlatemplates[Theme-Name]htmlcom_contentarticledefault.php
And for those of you, who don’t like to browse that file, and just want the solution, the following code worked for me:
1 2 3 | <?php echo JHtml::_('date', JFactory::getDate(), JText::_('DATE_FORMAT_LC1')) ?> |
<?php echo JHtml::_('date', JFactory::getDate(), JText::_('DATE_FORMAT_LC1')) ?>
The code itself is very simple. Basically, we are just getting the current date (second parameter), converting it to the correct date format, and then displaying it as HTML.
I hope this helps.
Tags: Date, Joomla, Localize, PHP
This entry was posted
on Tuesday, October 23rd, 2012 at 3:05 pm and is filed under Joomla, PHP.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
I am new to Joomla and don’t know how to add a link from a Joomla website to mine. I looged into administrator section and can’t find any that will let me put my link in the footer of the pages.
Descargar,
Not sure I fully understand your question. May be if you can explain a bit more with some example, I can try to help.