如題,task和api寫入的時區(qū)不一致.api打印出來的日志時區(qū)是utc的,task打印出來是cst的.
["context"]=>
array(0) {
}
["level"]=>
int(200)
["level_name"]=>
string(4) "INFO"
["channel"]=>
string(7) "default"
["datetime"]=>
object(Monolog\DateTimeImmutable)#10153 (4) {
["useMicroseconds":"Monolog\DateTimeImmutable":private]=>
bool(true)
["date"]=>
string(26) "2025-08-22 09:58:34.249670"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["extra"]=>
array(0) {
}
["message"]=>
string(57) "end_app\crontab\tasks\ChargeOrderExpiredCloseTask::handle"
["context"]=>
array(0) {
}
["level"]=>
int(100)
["level_name"]=>
string(5) "DEBUG"
["channel"]=>
string(7) "crontab"
["datetime"]=>
object(Monolog\DateTimeImmutable)#10889 (4) {
["useMicroseconds":"Monolog\DateTimeImmutable":private]=>
bool(true)
["date"]=>
string(26) "2025-08-22 17:58:01.366563"
["timezone_type"]=>
int(3)
["timezone"]=>
string(13) "Asia/Shanghai"
}
["extra"]=>
array(0) {
}
["formatted"]=>
string(101) "[2025-08-22 17:58:01] crontab.DEBUG: end_app\crontab\tasks\ChargeOrderExpiredCloseTask::handle [] []
app.php
'debug' => !(env("APP_ENV") == "ONLINE"),
'error_reporting' => E_ALL,
'default_timezone' => 'Asia/Shanghai',
'request_class' => Request::class,
'public_path' => base_path() . DIRECTORY_SEPARATOR . 'public',
'runtime_path' => base_path(false) . DIRECTORY_SEPARATOR . 'runtime',
'controller_suffix' => 'Controller',
'controller_reuse' => false,
無法完全復現,我在別的項目里,api時間又是正常的,很奇怪. 嘗試在bootstrap.php里設置默認時區(qū),是正常的.但是不知道問題在哪.其他項目沒出現異常