L
L
larik laravue2021-08-19 21:36:49
Laravel
larik laravue, 2021-08-19 21:36:49

How to make model field created_at converted to time zone?

in Laravel settings timezone is set to Moscow/Europe.
When data is added to the table, it is automatically saved in the Moscow time zone ( created_at, updated_at )

But when data is retrieved from the model and returned to the front, these two fields come out already converted to UTC, that is, 3 hours less.

What method to choose in order to deliver dates in Moscow time to the front with the least losses? Particularly interested. if we return whole bundles of goods.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
inFureal, 2021-08-19
@inFureal

there config/app.phpis a timezone there and change it.
If you need to cast to a different time zone, then the standard model fields and those cast to the cast datetime или dateare instances of Carbon.
Here everything is written, how to change what

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question