Parse and format date according to locale and timezone in Magento

Posted . Visible to the public.
$storeId = 1;
$dateFormatted = "Feb 18, 2015";


$timezone = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE, $storeId);
$locale = new Zend_Locale(Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE, $storeId));

$date = new Zend_Date(null, null, $locale);
$date->setTimezone($timezone);
$date->setDate($dateFormatted, $locale->getTranslation(null, 'date', $locale));

return $date->toString('YYYY-MM-dd');
Dan
Last edit
Dan
Keywords
date, zend_date, locale, timezone
Tags