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
.

This is what i was looking for to solve one of bug in my Module
Thnx duded .. It helped me a lot.
You are always welcome.
Thanks a lot, just what I was looking for as well. There must be a way to overide this and make that be set to the right one. I notice that a lot of the date columns in the database now have the wrong time entered, such as the cron_schedule table.
Hei Dan,
Thanks for commenting.. I am not sure what you are looking for. If you want to ignore this feature you may try to reset timezone setting in admin panel. If it doesn’t work.. definitely you can override the module. If you write me details what problems you are facing, then I may advice/help you more precisely.
Have fun with Magento
Hi,
I’m going to saving some date field(for example, “created at”) in Magento’s Database.
Should it saving by UTC format in date type field(database) ?
and then, Should I get the field’s value by following code ?
Mage::getModel(‘core/date’)->timestamp( Mage::getModel(‘myentity’)->getCreatedAt() );
thanks.
hi I want “tuesday,November 10,2010″ in this format. can you help me,please?
You’re great !
Best Engineer !
I respect for you.
it’s the same if we get the date from mysql now() function ? thx for your info , it’s help me
it is really helpfull
Hello ,,,
I have some different Problem regarding product date attribute ..
In site i have to set Product Status from front side for this i have added code like
$product = Mage::getModel(‘catalog/product’)->setStoreId(0)->load($productId);
$product->setStatus($newStatus);
$product->save();
this will set the new status to the product but change Special from date & special to date value ..
like 07/09/2011 to 09/07/2011
i have tried lot ,, but cant get any feasible solution …
Please help me to solve this issue …
Thanks in Advance
vishal surani
Very helpful, thanks a lot!
I used it to filter customers updated less than a week ago:
$lastDate = date(‘m/d/y h:i:s’, Mage::getModel(‘core/date’)->timestamp(time())-7*3600*24);
if ($customer->getUpdatedAt() > $lastDate)