Dev Teywa

Dev Teywa

  • NA
  • 250
  • 40.6k

how to fix timezone in pdo

May 10 2018 6:05 PM
hi, i want to fix timezone when i'm connect to db but i get this error 
 
 
my script 
error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE);
define('DB_DRIVER', 'mysql');
define('DB_PREFIX', 'em_');
define("DB_HOST", "localhost");
define("DB_USER", "root");
define("DB_PASSWORD", "");
define("DB_DATABASE", "db");
try {
$timezone = "Africa/Casablanca";
$DB = new PDO(DB_DRIVER . ':host=' . DB_HOST . ';dbname=' . DB_DATABASE, DB_USER, DB_PASSWORD, $dboptions);
$DB->exec("SET CHARACTER SET utf8");
$DB->exec("SET time_zone = '{$timezone}'");
} catch (Exception $ex) {
echo $ex->getMessage();
die;
}
?>