Skip to content

Instantly share code, notes, and snippets.

@ravixp
Last active July 12, 2017 17:47
Show Gist options
  • Select an option

  • Save ravixp/9d4ddc209cb5b38867cfdafdb1cfbbb7 to your computer and use it in GitHub Desktop.

Select an option

Save ravixp/9d4ddc209cb5b38867cfdafdb1cfbbb7 to your computer and use it in GitHub Desktop.
Magento 1: Format Date and Time using Configuration options
<!-- Date Short Type -->
<?php
// Short Type
//Output will be: 18/3/17
?>
<?php
$today = '2017-03-18';
$date = Mage::helper('core')->formatDate($today, Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, false);
echo $date;
?>
<!-- Date Medium Type -->
<?php
// Medium Type
//Output will be: 18 Mar, 2017
?>
<?php
$today = '2017-03-18';
$date = Mage::helper('core')->formatDate($today, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, false);
echo $date;
?>
<!-- Date Long Type -->
<?php
// Long Type
//Output will be: 28 March, 2017
?>
<?php
$today = '2017-03-18';
$date = Mage::helper('core')->formatDate($today, Mage_Core_Model_Locale::FORMAT_TYPE_LONG, false);
echo $date;
?>
<!-- Date Full Type -->
<?php
// Full Type
//Output will be: Friday, 18 March, 2017
?>
<?php
$today = '2017-03-18';
$date = Mage::helper('core')->formatDate($today, Mage_Core_Model_Locale::FORMAT_TYPE_FULL, false);
echo $date;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment