If you have ever looked into the way Magento actually generates times for your store, you probably know that it works from a base of using UTC throughout, and then calculates the time difference between this universal time and the timezone you have selected in admin. The idea behind this is to allow you to set different timezones per store or website and have them all work happily together because in fact they are all actually stored in UTC.
Unfortunately the only way to allow proper support for BST is to change this default timezone from UTC to Europe/London. So a word of warning, if you are in any way planning to use timezones other than Europe/London in your install, then you should not implement the changes here - you are unfortunately probably just going to have to put up with your store being an hour out for half of the year. If that's not you however, read on...
All of the changes here are very simple, start by copying the following core files:
app/code/core/Mage/Core/Model/Locale.php app/code/core/Mage/Core/Model/Date.php app/code/core/Mage/Cron/Model/Schedule.phpto their equivalent location under the local branch if they don't already exist there:
app/code/local/Mage/Core/Model/Locale.php app/code/local/Mage/Core/Model/Date.php app/code/local/Mage/Cron/Model/Schedule.phpEditing the first two files will change the storing of most timestamps in the database and backend to allow for BST (although we will be making another edit later on), and the third file will correct cron schedule timings (otherwise you will find jobs only queue if they scheduled an hour out).
So, open app/code/local/Mage/Core/Model/Locale.php and find the following line:
const DEFAULT_TIMEZONE = 'UTC';Change it to:
const DEFAULT_TIMEZONE = 'Europe/London';In the same file, find the following lines in the storeTimeStamp() method:
@date_default_timezone_set($timezone); $date = date('Y-m-d H:i:s'); @date_default_timezone_set($currentTimezone);Change them to the following:
@date_default_timezone_set(self::DEFAULT_TIMEZONE); $date = date('Y-m-d H:i:s'); @date_default_timezone_set(self::DEFAULT_TIMEZONE);Next open app/code/local/Mage/Core/Model/Date.php and find the following lines in the calculateOffset() method:
$result = date_default_timezone_set($timezone);and
date_default_timezone_set($oldzone);Change them to:
$result = date_default_timezone_set(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);and
date_default_timezone_set(Mage_Core_Model_Locale::DEFAULT_TIMEZONE);As you can probably see, all we have done is change the class constant for the timezone to Europe/London, and then referenced this in the other edits we have made.
Now you need to make sure cron continues to work correctly, so open app/code/local/Mage/Cron/Model/Schedule.php and find the following line:
$d = getdate(Mage::getSingleton('core/date')->timestamp($time));This is where cron decides what the current time is, and therefore whether or not to queue your jobs. If we leave this as it is, your jobs won't queue when you schedule them to - instead we just want to pull the server time here without an offset, so change it to the following:
$d = getdate();Obviously you need to make sure that the server is set to Europe/London also or this won't work.
Thats pretty much all the changes that are needed except that the guys at Varien decided they would put one more timezone reference in a file that you can't override in the local branch. So unfortunately to complete the process we need to make a change in, what I would consider to be a core file. Doing that is definitely not good practice and should be avoided unless absolutely necessary. Unfortunately I don't think there is an alternative in this case, so open app/Mage.php and find the following line:
date_default_timezone_set('UTC');Change it to:
date_default_timezone_set('Europe/London');Your store should now be running correctly in the Europe/London timezone and all new content should be recorded with this timestamp. Note however that existing content with a timestamp will not have changed from UTC (being the same as GMT) so will still show as an hour behind during the summer months.