A
A
abuamr2016-09-19 12:02:22
PHP
abuamr, 2016-09-19 12:02:22

How to optimize website time?

There is a server located in Russia, respectively, the time (timezone) is taken from the location of the server (Moscow). When logging in from other countries, the timezone shows the time and location of the server, not the country or timezone. How is it done, what are the ways?
For example, social networks show the time zone where a person is.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
firm, 2016-09-19
@abuamr

I'm using https://www.npmjs.com/package/jstz
Defines timezones on the client side.
Usage example: https://jsfiddle.net/5ybsto18/

var tz = jstz.determine();
var timezone = tz.name();

A
Andrey Mikhalev, 2016-09-19
@Endru9

In social networks, the city of your habitat is indicated, so it’s not difficult to see which city has which timezone in the database. In your case, you need to combine geoip and timezone.

A
Adamos, 2016-09-19
@Adamos

var t = new Date();
t.setTime(<?= strtotime('now') ?>);
write(t.toLocaleTimeString());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question