Opencart time zone change

This tutorial covers how to change the timezone in OpenCart as well as change time of the database.

Go to system/startup.php and find following lines of code:

if (!ini_get('date.timezone')) {

Replace with following lines of code by changing to your timezone


Synchronize PHP and Database Timezone

The query we use to set database timezone if you are super admin is below:

SET time_zone='offset';

But everyone has no super admin access so need to change in the code level. For that go to system/library/db/mysqli.php if you are using MySQLi and add code below after $this->connection->query(“SET SQL_MODE = ””);

$dt = new \DateTime();
$this->connection->query("SET time_zone='" . $dt->format('P') . "';");

With these changes your timezone in Opencart are changed.

Let us know if you find any issues, thanks a lot.


  1. hello,
    I read a few of the blogs related to changing timezones. but I wanted to know if this is the same for what I need related to launching scheduled sales and promotions… I want to launch a sale beginning 11-22-2019 (which should be mean 12:01 am). being in CA (pst) that means someone in NY should see it before anyone else. but when I do it, people in CA and HI can see the sale at the same time. any idea what I need to change or where to change so that the sale is only visible according to the users’ website timezone.


    • There is no Opencart module yet to show the special price or discount price as per the timezone.
      So, for now, we have to show all at once.


Please enter your comment!
Please enter your name here