Magento – Get current date time used in magento for saving data

datemagento-1.9timezone

I want to get current date time which is magento used for save data into database. I searched and get this line of code,

Mage::getModel('core/date')->date('Y-m-d H:i:s');

but this is not working for me. For test i create a product and check its details then i get this date,

[created_at] => 2015-11-18 07:47:35

but after that i echo above line then date is different. I get this date after echo Mage get date line

2015-11-17 21:52:05. I want function which provides datetime which is save in database.

Best Answer

Keep in mi mind that PDO is aware of the timezone set in your Magento installation, which is most likely causing you troubles.

When you try to work with automatic timestamps, try using Mage::getModel('core/date')->gmtDate('Y-m-d H:i:s').