Are you using date-time functions (date(), time(),now(), etc) directly inside magento ??? Think twice man !!!

Even though time is set properly in you server or you set right timezone in your php.ini file, you might be surprised to see the result of the following code :-

//This time will not match your server time
$now = time();
echo date('m/d/y h:i:s', time());

This is because whatever settings you have in your php.ini, Magento reset timezone to ‘UTC’ in Mage_Core_Model_App.

File:- \app\code\core\Mage\Core\Model\App.php Line:-255

date_default_timezone_set(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);

So, solution is set your targeted timezone in Admin->System->Configuration / General->Locale options and rather using date() function user the following code:-

$now = Mage::getModel('core/date')->timestamp(time());
echo date('m/d/y h:i:s', $now);

That’s it, have happy time with Magento :-) .

About these ads