I want to display only date from the below function.
$this->formatTime($item->getCreatedTime(), 'short', true);
This displays both date and time of creation something like:
3/21/2017 11:42 AM
I want only 3/21/2017
I want to display only date from the below function.
$this->formatTime($item->getCreatedTime(), 'short', true);
This displays both date and time of creation something like:
3/21/2017 11:42 AM
I want only 3/21/2017
You can try this
$date = $this->formatTime($item->getCreatedTime(), 'short', true);
$newdate = date('m/d/Y', strtotime($date));
echo $newdate; // Output : 3/21/2017
You can use date format
echo date('m/d/Y', $this->formatTime($item->getCreatedTime(), 'short', true));
Answers by other users are not correct, using date will not take Magento's time zone configuration into account.
Instead following should be used:
Mage::getModel('core/date')->date('m/d/Y', $item->getCreatedTime());