R
R
Ratibor2020-01-22 07:30:14
JavaScript
Ratibor, 2020-01-22 07:30:14

How to determine today's date in Moscow?

How can I use js to determine the current date in Moscow?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-01-22
@RatiboR1978

function getDateInTimeZone(utcOffset, date = new Date()) {
  const utcTime = date.getTime() + date.getTimezoneOffset() * 60000;
  return new Date(utcTime + utcOffset * 3600000);
}


const moscowDate = getDateInTimeZone(3);
const newYorkDate = getDateInTimeZone(-5);
const tokyoDate = getDateInTimeZone(9);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question