A
A
Artur Kosikov2018-05-24 22:01:15
Yii
Artur Kosikov, 2018-05-24 22:01:15

How to correctly display the date / time, taking into account the time zone?

The database stores the date/time of the post (field DATETIME).
Installed in B.D. everything is written in GMT. I expect the formatter to increase the value from the DB by 3 hours.
Yii::$app->formatter->timeZone = 'Etc/GMT+3';

// $message->mess_date = 2018-05-24 18:38:00
Yii::$app->formatter->asDatetime($message->mess_date, "php:d-m-Y H:i");
// Выводит 24-05-2018 15:38
// А я ожидаю: 24-05-2018 21:38

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-05-24
@atillus

Good evening.
If you believe this information, then you get the correct time, that is, minus three hours.
To get what you need, replace "plus" with "minus" and get the desired "24-05-2018 21:38"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question