laravel mysql時區設定問題

2021-08-03 11:54:45 字數 633 閱讀 8130

在**中有設定資料庫連線的時區,並建立了資料庫連線:

$this->mysql_config = config::get('database.connections.mysql');

$this->mysql_config['options'] = array(

pdo::mysql_attr_init_command => "set time_zone = ''",

);    

......

......

$this->mysql_config['database'] = $this->db_name;

config::set("database.connections.", $this->mysql_config);

......

......

db::connection($this->db_name);

但是當使用如下**執行sql時設定的時區並沒有生效(使用了預設的mysql連線):

$result = db::select(db::raw($sql));

使用如下**,則時區設定生效:

$result = db::connection($this->db_name)->select(db::raw($sql));

mysql 時區設定 mysql時區檢視與設定

一.檢視資料庫時區 show variables like time zone mysql show variables like time zone variable name value system time zone cest time zone system 1.全域性引數system t...

NSData 日期格式化 顯示格式 時區獲取設定

nsdateformatter格式化日期 1.日期物件格式化為字串 2013 07 29 15 20 59 2013年07月29日 日期物件 字串 nsdate nowdate nsdate date nsdateformatter dateformatter nsdateformatterallo...

修改mysq時區及linux時區

1.mysql 找到my.cnf檔案,一般在 etc 下面,或者 etc mysql 下面,在mysqld裡面新增一句 default time zone 8 00 重啟mysql即可,service mysql resart 2.修改linux時區為上海 cp usr share zoneinfo...