Magento and UTC on Hypernode

in MagentoTroubleshootingUsage Tags: Magento

Getting Magento to work with system timezone set to UTC

 

As you probably know, the world is divided in a bunch of time zones. Because Hypernode is hosted in the cloud, the system timezone is set to UTC. This is because we cannot always know in what timezone the server will be hosted, but we want to deliver a consistent system timezone for our customers.

You will probably want to work in a different timezone OR show a different timezone to your customers. So this is an issue not only when dealing with a Hypernode, but also when operating an intercontinental shop.

TL;DR:

    1. You should set the global timezone for Magento to the UTC-equivalent GMT Standard Time.
    2. Then, set the timezone for all websites to your local timezone.
    3. If you are in The Netherlands, choose “Europe/Berlin” if “Europe/Amsterdam” is not in the list.

So what is the problem?

The timezone nut is actually not that hard to crack. But Magento has some internals that loose the sense of time zones by converting to and from an ancient time format called the Unix Time. This is a time format does not have a sense of time zones.

This problem crops up when calculating stuff involving dates and shows up as weird problems like:

  1. Catalog price rules will disappear after a few hours.
  2. Magento cronjobs email you with the error “Too late for schedule”.

All of this is because MySQL and Magento do not agree on the timezone to use and also do not communicate correctly.

The solution

To solve this problem, Magento should operate on the same timezone as the server. Then, to display all dates and times on your websites and stores as you like them, set the timezone for all websites to your preferred timezone.

set your global timezone settings to GMT

Set your global timezone settings to GMT Standard Time

1. Set the global timezone to GMT or UTC

If Magento does not support the UTC timezone, then select its equivalent GMT Standard Time.

  1. Go to System -> Settings
  2. Edit your default scope
  3. Go to Configuration -> General -> General -> Locale Options
  4. Select GMT Standard Time

Note that this is not UTC, but it is in almost all cases exactly the same as UTC, which is good enough. UTC and GMT both do not follow summer time or winter time. They only differ on leap seconds.

2. Set your default website scopes to your preferred time zones

Next are your website scopes. These will ensure that your websites display Dutch, Chinese or American order and shipping times, or some other time according to your settings.

  1. Go to System -> Settings
  2. Select the scope for each of your websites. The example edits Gudz.nl and repeats the process for Judopak and Karatepak.
  3. Go to Configuration -> General -> General -> Locale Options again.
  4. Select W. European Standard Time (Europe/Berlin or Europe/Amsterdam) or select some other timezone appropriate for the location of your customers.
  5. Repeat for the next website.

Please note: Europe/Amsterdam is not available in all Magento version. The timezone Europe/Berlin is equivalent.

 

Edit the timezone of each of your websites

Edit the timezone of each of your websites

Change the timezone of your websites to W. Europe Standard Time or appropriate timezone

Change the timezone for each of your websites to point to W. Europe Standard Time (Europe/Berlin or Europe/Amstyerdam) or some other timezone

4