Php 根据Laravel 5中的系统时区配置Laravel时区
我正试图在config/app.php上根据我的系统时间自动设置CentOS VM上的时区配置Php 根据Laravel 5中的系统时区配置Laravel时区,php,laravel,laravel-5,centos,timezone,Php,Laravel,Laravel 5,Centos,Timezone,我正试图在config/app.php上根据我的系统时间自动设置CentOS VM上的时区配置 'timezone' => 'America/New_York', 我已经尝试在config/app.php上面添加了这几行代码 以上这些似乎都不起作用 如何进一步调试此功能?您可以尝试以下方法: $now = new DateTime(); $tz = $now->getTimezone(); $tz = $tz->getName(); 如果上述方法不起作用,我建议你看看 您的
'timezone' => 'America/New_York',
我已经尝试在config/app.php上面添加了这几行代码
以上这些似乎都不起作用
如何进一步调试此功能?您可以尝试以下方法:
$now = new DateTime();
$tz = $now->getTimezone();
$tz = $tz->getName();
如果上述方法不起作用,我建议你看看
您的config/app.php文件如下:
<?php
# include Carbon
use Carbon\Carbon;
return [
.
.
.
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => Carbon::createFromTimestamp(0, 'America/New_York')->timezone->getName(),
.
.
.
];
确保清除缓存以查看更改:php artisan config:cache如何使用?类似于碳::createFromTimestamp0,“美国/纽约”->getTimezone;我尝试了这个我得到的:检查这个链接以获得更多关于错误的信息-确保你添加了这个使用碳\碳;你的档案也一样
<?php
# include Carbon
use Carbon\Carbon;
return [
.
.
.
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/
'timezone' => Carbon::createFromTimestamp(0, 'America/New_York')->timezone->getName(),
.
.
.
];
Route::get('/test-timezone', function() {
dd(\Config::get('app.timezone'));
});