Laravel 调度器时区
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34801327/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel scheduler timezone
提问by Petah
How do I set the Laravel scheduler to run a task at a specific time in a certain timezone? The server is set to UTC, but I want to run the task at 12 noon every Monday in the Pacific/Auckland
timezone.
如何设置 Laravel 调度程序在特定时区的特定时间运行任务?服务器设置为 UTC,但我想在Pacific/Auckland
时区的每个星期一中午 12 点运行任务。
E.g. this will work, but the timezone is UTC:
例如,这会起作用,但时区是 UTC:
protected function schedule(Schedule $schedule) {
$schedule->command('run-report')->weekly()->mondays()->at('12:00'));
}
回答by jedrzej.kurylo
You can do it using timezone()method:
您可以使用timezone()方法来做到这一点:
$schedule->command('run-report')->weekly()->mondays()->at('12:00')->timezone('Pacific/Auckland');