E
E
Elizaveta Cezurk2020-10-30 13:34:00
JavaScript
Elizaveta Cezurk, 2020-10-30 13:34:00

How to set standard JS time in Moscow?

As I know, a specific time zone can be set on the server, I have a time zone set to Moscow time.
But I have +2 hours relative to Moscow, I made a countdown timer, but since JS time is local, that is, relative to the user, the timer does not work correctly for me.
Is it possible to somehow set the JS time to Moscow time, and if so, how?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2020-10-30
@Seasle

new Date(Date.parse('2020-10-30T10:00:00.000Z')); // Добавит таймзону
new Date(Date.parse('2020-10-30T10:00:00.000')); // Не добавит таймзону

T
Tim, 2020-10-30
@Tim-A-2020

function getMoscowDate() {
    var offset = +3;
    return new Date(new Date().getTime() + offset * 3600 * 1000).toUTCString().replace(/ GMT$/, "");
}
console.log(getMoscowDate());

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question