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

Wrong Date & Time For Locale GMT
 
Ashley
Member
 
Total Posts:  51
Joined:  2008-07-23
 

I have set my locale options to be GMT(Europe/London) and the server date and time is configured correctly, however when I modify a customers record and then retrieve the customers attributes, the ‘updated_at’ is exactly an hour behind the correct date and time of the server. I need this date and time to be correct because I am synchronizing customers with a backend system and need to know if there have been any modifications on the customers account. By being an hour out, there is an hour timeframe where I could miss any updates made by a customer!

Has anybody had any similair problems or is this the way Magento works? Surely Magento just uses the server time when specifying the current time for attributes.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ashley
Member
 
Total Posts:  51
Joined:  2008-07-23
 

Currentley the UK is in BST timezone not GMT but Magento does not cater for this. This means that the application will work correctly for half the year and not the other! I don’t really want to code my application to handle this when Magento should really be capable of doing this. Does anybody know how to get magento to return a date/time based upon daylight saving?

 
Magento Community Magento Community
Magento Community
Magento Community
 
zemigata
Jr. Member
 
Total Posts:  20
Joined:  2008-07-24
Milan
 

is there a workaround?

Z

 
Magento Community Magento Community
Magento Community
Magento Community
 
Bindi
Jr. Member
 
Total Posts:  1
Joined:  2009-05-23
 

bump.....
is there an answer to this one?

thanks
bindi

 
Magento Community Magento Community
Magento Community
Magento Community
 
Gummi
Jr. Member
 
Total Posts:  25
Joined:  2008-02-12
 

I’m experiencing this as well....

 
Magento Community Magento Community
Magento Community
Magento Community
 
Paragon
Jr. Member
 
Total Posts:  5
Joined:  2009-09-23
 

Does anyone have a solution to this issue that affects all UK users for half of every year?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Paragon
Jr. Member
 
Total Posts:  5
Joined:  2009-09-23
 

Just created a new thread elsewhere to hopefully get some attention focused on the issue:
http://www.magentocommerce.com/boards/viewthread/56120/

 
Magento Community Magento Community
Magento Community
Magento Community
 
Ashley
Member
 
Total Posts:  51
Joined:  2008-07-23
 

I did manage to fix this after weeks of bug hunting!

I noticed that times were being saved in Magento as UTC regardless of what timezone the server was configured for. I ran a non magento test script on the server to ensure that the PHP config was correct and it was, implying that this was definaetly a Magento problem. So I simply did an “ack UTC” across the whole magento directory which pointed me to a suspicous file: app/code/core/Mage/Core/Model/Locale.php

Basically we changed the default timezone constant on line 32 to this

const DEFAULT_TIMEZONE  'Europe/London';

This fixed it for us and now we have BST working correctley and we are no longer an hour out. I know alot of systems use UTC as the base timezone but not catering for BST is a stupid move by Magento.

Hope that helps anyone else stuck on this

Regards
Ashley

 
Magento Community Magento Community
Magento Community
Magento Community
 
thewolf
Jr. Member
 
Total Posts:  6
Joined:  2009-08-26
 

We’ve reported this issue to the Magento support, but it looks like they current don’t have plans to fix it ...
You should report it as well, so it may get escalated and eventually fixed!

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nikola99
Member
 
Total Posts:  47
Joined:  2010-04-09
 

This works for me

echo date('l, F j, Y, H:i:s'Mage::app()->getLocale()->storeTimeStamp());
 
Magento Community Magento Community
Magento Community
Magento Community
 
edmondscommerce
Guru
 
Avatar
Total Posts:  342
Joined:  2008-08-26
 

nice one nikola, that works perfectly - that’s worth remembering

 
Magento Community Magento Community
Magento Community
Magento Community
 
Emico
Member
 
Total Posts:  51
Joined:  2009-07-22
Netherlands
 
edmondscommerce - 22 October 2010 01:32 AM

nice one nikola, that works perfectly - that’s worth remembering

I found in app/Mage.php on line 646 that Magento sets the default_timezone tot ‘UTC’.

This ensures that it goes wrong, the value in the configuration state is thus ignored.

Anyone have any idea why Magento do this?
It seems they want to compare the installation date, but why do they will not try this?

date_default_timezone_set(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);

After this fix, you can use the native date functions as normal.

But why set Magento the timezone to UTC, and WHY why is not restored.

 
Magento Community Magento Community
Magento Community
Magento Community
 
nikola99
Member
 
Total Posts:  47
Joined:  2010-04-09
 

Just guessing here, but it’s probably so you could have multiple stores with different time zones and all the DB records would be in UTC. You could even move your server from one timezone to another and everything should still work as long as your server’s time zone was set correctly.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Emico
Member
 
Total Posts:  51
Joined:  2009-07-22
Netherlands
 
nikola99 - 25 October 2010 05:45 AM

Just guessing here, but it’s probably so you could have multiple stores with different time zones and all the DB records would be in UTC. You could even move your server from one timezone to another and everything should still work as long as your server’s time zone was set correctly.

Right, but you’d still expect them to turn back after that comparison?

 
Magento Community Magento Community
Magento Community
Magento Community
 
husseycoding
Jr. Member
 
Avatar
Total Posts:  30
Joined:  2010-06-18
UK
 

I have written a blog post on how to get Magento to properly cater for BST here.  It also covers how to get cron to continue to schedule correctly (with just the changes discussed here cron jobs will only queue if they are scheduled an hour out).

 
Magento Community Magento Community
Magento Community
Magento Community
 
idrivetoofast123
Jr. Member
 
Total Posts:  17
Joined:  2010-05-28
 
nikola99 - 05 October 2010 11:10 AM

This works for me

echo date('l, F j, Y, H:i:s'Mage::app()->getLocale()->storeTimeStamp());

Put

date('l, F j, Y, H:i:s'Mage::app()->getLocale()->storeTimeStamp());
at the top of functions.php and it fixed most of our issues.
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top