diegovarussa
5/15/2013 - 2:46 PM

Magento Time e Date.

Magento Time e Date.

<?php

//Magento's timestamp function makes a usage of timezone and converts it to timestamp
$currentTimestamp = Mage::getModel('core/date')->timestamp(time());
//The value may differ than above because of the timezone settings.
echo $date = date('Y-m-d', $currentTimestamp);
	
echo $currentDate = Mage::getModel('core/date')->date('Y-m-d');

// Formatting any date in any format
$anyDate = '2011-12-11';
$dateTimestamp = Mage::getModel('core/date')->timestamp(strtotime($anyDate));
echo $currentDate = date('d.m.Y', $dateTimestamp);
// OR
$anyDate = '2011-12-11';
echo $currentDate = Mage::getModel('core/date')->date('d.m.Y', strtotime($anyDate));

// Predefined date formatting
$dateToFormat = '2011-12-11';
Mage::helper('core')->formatDate($dateToFormat, 'medium', false);