title: MYSQL set timezone in PHP code
body: <p>How can I change MYSQL TIMEZONE to GMT format like this function in PHP:
  /<em>SET GMT TIMEZONE</em>/
  date_default_timezone_set('Etc/GMT');</p>
  
  <p>My DB class is here:</p>
  
  <pre><code>class DB {
      private static $instance;
      private $MySQLi;
  
      private function __construct(array $dbOptions){
  
          $this-&gt;MySQLi = @ new mysqli(   $dbOptions['db_host'],
                                          $dbOptions['db_user'],
                                          $dbOptions['db_pass'],
                                          $dbOptions['db_name'] );
  
          if (mysqli_connect_errno()) {
              throw new Exception('Database error.');
          }
  
          $this-&gt;MySQLi-&gt;set_charset("utf8");
      }
  
      public static function init(array $dbOptions){
          if(self::$instance instanceof self){
              return false;
          }
  
          self::$instance = new self($dbOptions);
      }
  
      public static function getMySQLiObject(){
          return self::$instance-&gt;MySQLi;
      }
  
      public static function query($q){
          return self::$instance-&gt;MySQLi-&gt;query($q);
      }
  
      public static function prepare($q){
          return self::$instance-&gt;MySQLi-&gt;prepare($q);
      }
  
      public static function esc($str){
          return self::$instance-&gt;MySQLi-&gt;real_escape_string(htmlspecialchars($str));
      }
  
  }
  </code></pre>
  
  <p>And my queries like this in other files:</p>
  
  <pre><code>DB::query('UPDATE `calendar_data` SET `data` = "'.DB::esc(json_encode($array)).'", `upcoming_time` = "'.date('Y-m-d H:i:s', $upcoming).'", `time_now` = NOW() WHERE `id` = "1"');
  </code></pre>
  
  <p>Where should I insert my query to the class for run it once?</p>
  
  <p>Thanks!</p>
  
  <pre><code>$this-&gt;MySQLi-&gt;set_charset("utf8");
  $this-&gt;MySQLi-&gt;query("SET timezone = 'GMT'");
  </code></pre>
  
  <ul>
  <li>
  Doesn't work. If I use NOW(), server time was inserted (GMT-4). Where is a problem???</li>
  </ul>