How to implement the output of time in the chat in accordance with the time zone? I tried on js time zone to write to cookies

var TimeZone = Dates.getTimezoneOffset()/60; document.cookie = "TimeZone="+TimeZone; 

and then in php record the time in UTC in the chat and bring such manipulations

 date("dmY H:i:s", time() + ($_COOKIE['TimeZone'] * -1) * 60 * 60); 

But I did not get the desired result, it is normal for me, and for some it does not correctly show.

Update

date_default_timezone_set("UTC"); I added this to the file before sending SMS to the database, after I output it, but the browser does not translate to the desired date, I do not use the code in the output above.

  • when outputting time, it is displayed locally by default. So pass in utc, the browser will translate itself when outputting, and even better the unix timestamp - Grundy
  • do you drive php right away? I talked about the client side: received from php unixtimestamp - did new Data (time) - derived the value received - received local time - Grundy

0