Maybe someone could help me out here. I'm trying to get the correct date/time for this variable.

<?php echo $rma['created_time']; ?>

I've tried lots of ways. Mage::getModel('core/date')->date("F j, Y g:i a"); is the date format I'm trying to get but I need it to convert $rma['created_time']; to the new format.

Here's one attemp but it creates a new date on each page load.

<?php $rma['created_time'] = Mage::getModel('core/date')->date("F j, Y g:i a");echo $rma['created_time']; ?>


2 Answers 2


You can use below code to format date:

   $dateTimestamp = Mage::getModel('core/date')->timestamp(strtotime($rma['created_time']));
   echo date('F j, Y g:i a', $dateTimestamp);

Here are some additional examples for you on how to use methods built into Magento.

$now   = Mage::getModel('core/date')->gmtDate(); // 2016-05-15 19:05:15
$full  = Mage::helper('core')->formatDate(null, Mage_Core_Model_Locale::FORMAT_TYPE_FULL, true); // Sunday, May 15, 2016 3:05:15 PM America/New_York
$long  = Mage::helper('core')->formatDate(null, Mage_Core_Model_Locale::FORMAT_TYPE_LONG, true); // May 15, 2016 3:05:15 PM EDT
$med   = Mage::helper('core')->formatDate(null, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true); // May 15, 2016 3:05:15 PM
$short = Mage::helper('core')->formatDate(null, Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, true); // 5/15/2016 3:05 PM

I have also become a big fan of the Zend_Date class. You can do some really cool stuff with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.