M
M
McMike2017-09-05 14:59:17
PHP
McMike, 2017-09-05 14:59:17

What is the problem with the time zone?

The timezone is set in the code, the current date $date = date(DATE_ISO8601) is taken,
it is equal to, for example, '2017-09-05T14:54:36+0300'
and passed further to the function:
$dt = new \DateTime(date(DATE_ISO8601, strtotime( $date)));
$date = $dt->format('Ymd');
$time = $dt->format('H:i:s');
as a result, the variable $time = '14:54', i.e. lost 3 hours from the time zone. How can I fix this so that the time is '17:54'?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Kuzmichev, 2017-09-05
@Assargin

And where did you get the idea that the time should be 17:54?
2017-09-05T14:54:36+0300should be read as "September 5, 2017, time 14:54:36 UTC + 03 time zone"
The same time in UTC would look like this:2017-09-05T11:54:36+0000

A
Adamos, 2017-09-05
@Adamos

php.net/manual/en/datetime.settimezone.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question