Magento – Translate month in ‘Get date’

datemagento-1.7

I have a news page in my magento store which is displaying news posts with a publish date, my store is built in 2 languages, the code which is creating the format:

public function getPublishDate($format = 'd F Y')
    {
        return $this->getDateCreatedFormated($format);
    }

This is the code in my Code\Model folder.

The problem is in, both languages the month is shown in English, how can i make sure the English pays shows the English date, and my other language, shows, ofcourse, the other languaeg.

Best Answer

Not having seen the code that you have, which formats your date, I am not sure if you are already using the correct formatting 'the magento way'

However, in case not, try this, and see if it works: (note, have not tested this)

See Mage_Core_Helper_Data::format(), which claims it will format the date according to the locale settings.

/**
 * Format date using current locale options
 *
 * @param   date|Zend_Date|null $date in GMT timezone
 * @param   string $format (full, long, medium, short)
 * @param   bool $showTime
 * @return  string
 */
public function formatDate($date=null, $format='short', $showTime=false)
{
....
}

so a call like this will potentially result in the correct 'locale specific' result:

Mage::helper('core')->formatDate($dateToFormat, 'medium', false);

Hope that helps.

Related Topic