Cheetah
Cheetah

Reputation: 21

How to change Server Time Zone in Opencart?

We use Opencart 1.5.6 and our server time is Eastern Time, but our shop is in Pacific time... How do we change the server time for our store?

Upvotes: 2

Views: 6190

Answers (2)

Abdelrhman Adel
Abdelrhman Adel

Reputation: 1187

OC sets the time zone to UTC if the value of date.timezone in php.ini file is not defined

You can find that piece of code in <OC_ROOT>/system/startup.php

if (!ini_get('date.timezone')) {
    date_default_timezone_set('UTC');
}

So you just need to change this piece of code, or re-define the value date.timezone

Upvotes: 1

You Old Fool
You Old Fool

Reputation: 22959

You can set the timezone in your index.php with ini_set(). You also need to set the MySQL timezone since OpenCart queries use NOW() quite often.

ini_set('date.timezone','America/Los_Angeles');
$db->query("SET time_zone = '" . date('P') . "'"); 

Make sure you add this to both index.php files - admin and catalog, somewhere after:

$registry->set('db', $db);

Upvotes: 3

Related Questions