Skip to main contentSkip to footer

How to Change OpenCart Timezone

Rupak Nepali
Share:
How to Change OpenCart Timezone

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')) {
	date_default_timezone_set('UTC');
}

Replace with following lines of code by changing to your timezone

date_default_timezone_set('Australia/Sydney');

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.

Comments

Join the conversation and share your thoughts

Leave a Comment

Your comment will be reviewed before publishing.

Be the first to comment on this post!

Innovation

Let's Make Something Amazing Together

We always provide our best creative ideas at the highest level. Tell us about your project and we will make it work.

InnovateBringing innovative solutions to complex problems
AutomateStreamlining processes through automation
DominateLeading the market with exceptional results
Build Smarter and Launch FasterEfficient development for rapid deployment