L
L
lolka022018-11-08 15:43:48
JavaScript
lolka02, 2018-11-08 15:43:48

How to properly set time with timezones in yii2+js?

I work locally, my zone is +7, when time() outputs the time according to the time zone +00, I set the time zone Yii::$app->setTimeZone('Europe/Moscow'); time() also displays +00 , but date('dmy H:i:s') is displayed in Moscow,

<div class="time" data-time="<?= time()?>">
<script>
var time = $('.time').attr('data-time');
var date = time * 100;//значение выводится по поясу +7,
</script>

How to synchronize all this so that everything is displayed in Moscow?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2018-11-12
@webinar

time() is time zone independent. This is the timestamp in seconds since Jan 1, 1970 00:00:00 GMT
GMT, Carl

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question