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 1

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.

Was my answer helpful? You can accept it as a solution.
175+ Professional Extensions for M1 & M2
Need a developer?Just visit Contact Us Now