Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How to get the time zone of user? 
 
muk_t
Sr. Member
 
Total Posts:  226
Joined:  2012-07-24
 

Hi

I want to access the timezone of the Magento website users using php code.

Suppose a user is accessing my site from Australia, I want to get the timezone set on his system.

Is it possible using PHP. If yes please guide me.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
Kaforad
Jr. Member
 
Total Posts:  10
Joined:  2009-01-31
 

Hi ,

To get configuration time zone(i.e. time zone set during magento configuration) use:

Mage::app()->getStore()->getConfig(’general/locale/timezone’)

to output the value you can use var_dump to check if it is what you want

var_dump( Mage::app()->getStore()->getConfig(’general/locale/timezone’));

To list all available time zones use:

Mage::getModel(’core/locale’)->getOptionTimezones()

var_dump(Mage::getModel(’core/locale’)->getOptionTimezones());

You can also get the time zone using this sql script in your magento database

select value from core_config_data where path=’general/locale/timezone’

 
Magento Community Magento Community
Magento Community
Magento Community
 
muk_t
Sr. Member
 
Total Posts:  226
Joined:  2012-07-24
 

@Kaforad

You provided very good and useful information.
But i want to access the remote user time zone.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
Suma Tata
Jr. Member
 
Total Posts:  16
Joined:  2012-01-29
 

echo date("Y-m-d h:i:s"Mage::getModel('core/date')->timestamp(time()));
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top