D
D
Darkhan Kamaliev2019-07-24 07:06:17
Laravel
Darkhan Kamaliev, 2019-07-24 07:06:17

Misunderstanding of storing date-time(in UTC) in laravel base?

Good day.
Set for model

protected $dates = [
        'created_at',
        'updated_at',
        'arrivalDate',
        'dateOfDeparture',
    ];

In the UserFactory (for the seeder) set the values
'arrivalDate' => '2019-05-28 23:31:19',
        'dateOfDeparture' => '2019-05-28 23:31:19',

screenshot from database
5d37d8eb0638c291033025.png

created_at and updated_at are converted to UTC (relative to my time), but my fields are not..
Am I doing something wrong? Or how is it supposed to work? The project is clean (I fill the first table).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Wells, 2019-07-24
@darakanoit

How does he know what timezone your LINES are in (these are not dates, not even close)?
created_at and updated_at are created by a regular DateTime already in the required time zone, and are not converted (and should not be).
Do it in UserFactory 'arrival_date' => now()and you will be happy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question