cancel
Showing results for 
Search instead for 
Did you mean: 

Change date format for an attribute

Change date format for an attribute

Hello,

The date format for my begin_date attribute is displaying like : 2015-04-25 00:00:00
and i want it like : 25 04 2015.

 

I tried 

 

<?php 
    echo $this->helper('core')->formatDate(getbegin_date(), Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); 
?>

But it Dont work

 

I tried 

$begin_date = '2011-12-11';
    Mage::helper('core')->formatDate($begin_date, 'medium', false);        echo $_product->getData('begin_date') ?>

But it dont work...

 

Thanks for your help

1 REPLY

Re: Change date format for an attribute

Try this:

$source = '2015-04-25 00:00:00';
$date = new DateTime($source);
echo $date->format('d m Y'); // 25 04 2015

 It will work.

Found something useful, please give "Kudos" or "Accept as Solution" for Token of Appreciation.
Free Magento Extensions : https://magecomp.com/free-magento-extensions.html