Magento and BST Timezone issue

Magento and BST Timezone issue

September 14, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento and BST Timezone issue

Magento BST Timezone Issue: A Comprehensive Solution

As a senior developer specializing in e-commerce platforms, I’ve encountered this issue many times while working on Magento projects for clients like Laravel Company. The discrepancy between the displayed order creation time and the database-stored timestamp can be quite puzzling. Let’s dive into the root causes and potential solutions.

Understanding the Issue

The core problem lies in how Magento handles timezones, especially during daylight saving transitions like BST (British Summer Time). Despite your server being configured to Europe/London, which includes BST adjustments, it seems that Magento isn’t always applying these changes correctly when storing order data.

Why Doesn’t Magento Support BST?

I wouldn’t say that Magento doesn’t support BST. Instead, the issue likely stems from how the timezone configuration is applied or interpreted within the Magento ecosystem.

Potential Causes and Solutions

1. Incorrect PHP Configuration

Ensure that your PHP configuration matches the server’s timezone everywhere:

date.timezone = Europe/London

Check this setting in all relevant .ini files, including php.ini, /etc/php.d/magento.ini, and any overrides specific to Magento.

2. Database Connection Issues

Verify that your database connection is using the same timezone configuration as your server and PHP settings:

$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
$connection->query("SET time_zone = '+0:00';");

This command ensures that the database connection uses the local timezone.

3. Magento Core Files

If the above steps don’t resolve the issue, you might need to modify some core files:

  1. Open app/code/core/Mage/Sales/Model/Order.php.
  2. Find the line $this->setCreatedAtVarienDate($time).
  3. Replace it with:
$this->setCreatedAtVarienDate(new Varien_Datetime_Date($time, Varien_Date::TIMEZONE_SERVER));

This change forces Magento to use the server’s timezone when setting order timestamps.

Code Example: Fetching Orders Since Last Sync

You’ve provided some excellent code for fetching new orders since the last sync. However, let’s optimize and enhance it:

private function GetNewOrderIncrementIds($API_Data = '')
{
    // ... (same as before)

    // Load Order Collection with Proper Timezone Filter
    $order_collection = Mage::getModel('sales/order')
        ->getCollection()
        ->addAttributeToFilter(
            'created_at',
            array(
                'from' => $fromDate,
                'to'   => $now->format('Y-m-d H:i:s'),
                'date' => true
            )
        );

    // ... (rest of the code)
}

Notice the 'date' => true parameter added to the filter. This ensures that Magento interprets the created_at field as a date instead of a string.

Conclusion

Magento’s BST timezone issue is usually due to a mismatch between server, PHP, and database configurations or core file interpretations. By carefully managing these settings and possibly modifying some core files (with caution), you can resolve this discrepancy and maintain accurate order timestamps.

Remember to always test changes in a staging environment before deploying them to production. If you require further assistance or more complex solutions like custom timezone detection, feel free to contact us at Laravel Company. Our team of experienced Magento developers is ready to help optimize your e-commerce performance.

Database Configuration Orders Errors

Our network