如何获取linux操作系统,mysql数据库,laravel的时区设置
linux
date +"%Z"
mysql
show variables like "%time_zone%"
laravel
date
完整php代码实现
$dbVariables = DB::select('show variables like "%time_zone%"');
$dbTimeZone = [];
foreach ($dbVariables as $variable) {
$dbTimeZone[$variable->Variable_name] = $variable->Value;
}
$envInfo = [
'timezone' => [
'operator_system' => shell_exec('date +"%Z"'),
'db_system' => $dbTimeZone['system_time_zone'],
'db_timezone' => $dbTimeZone['time_zone'],
'laravel' => config('app.timezone'),
],
'date' => [
'system' => shell_exec('date'),
'php' => date('D M d H:i:s e Y'),
],
];