C
C
chelkaz2017-04-22 19:39:40
Laravel
chelkaz, 2017-04-22 19:39:40

Laravel 5.4 does not spell TIMESTAMP correctly. Why?

In php.ini date.timezone = Europe/Moscow;
$date->getTimestamp() Shows correctly.
The server time is correct: Europe/Moscow
# date
Sat Apr 22 19:03:15 MSK 2017
Checking the base time:
SELECT CURRENT_TIMESTAMP;Shows the correct one.
In Laravel app/config is - 'timezone' => 'Europe/Moscow',
I check in Laravel: Carbon\Carbon::now() Veronoe!
But if the queues work and an error occurs, then the failed_jobs table writes the date 3 hours earlier in the failed_at field . That is, for example, not 19:00 but 16:00
Why!??

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2017-04-22
@alexey-m-ukolov

They are executed through cli, cli has its own php.ini. Check the zone there. Just to get started, on the command line, runphp -r "echo date('H:i:s');"

A
Andrzej Wielski, 2017-04-22
@wielski

Laravel writes the date in UTC format.
Write your date fields in the model, and then work with it through Carbon to your heart's content.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question