How to find Server time in magento

December 29, 2010 | In: Magento, php, web development

Many times developer gets the time problem during project development. Because he works on date function which provides by PHP but site works on different server which time is different from developer country. So for this case you can use magento time which priovides by Magento self. It Manage the server time.

<?php
echo Mage::getModel('core/date')->timestamp(time());
?>

This line will print the time in string format so you can convert into date format according to your requirement:

<?php
echo date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));
?>