Reputation: 75
I have simple code using Carbon on Laravel as follow:
$dt = Carbon::now();
$user_log = new UserLog;
$user_log->created = $dt->toDateTimeString();
$user_log->save();
And the result is different in controller and in class queue process(ex : class Task extends Job implements ShouldQueue)
result :
2016-04-20 14:32:02 // my setting timezone that i want
2016-04-20 07:32:05 //UTC (ON queue process)
anyone have clue about this ?
Upvotes: 0
Views: 734
Reputation: 75
$dt = Carbon::now()->setTimezone('Asia/Jakarta');
i just put that setTimezone on my queue job and problem solved
Upvotes: 0
Reputation: 10533
My guess would be that Laravels queue is using the command line version of PHP, which happens to be different to whatever apache/nginx is serving.
On the command line you can use the following command to find your PHP version:
php --version
This should give you some output like below:
PHP 5.5.22 (cli) (built: Mar 9 2015 21:14:11)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
In your laravel app echo phpinfo()
and see if the version matches the output from the command line.
Upvotes: 1