@generate
...

Как установить часовой пояс МСК?

С базы получаю время и на сайте должен быть таймер он почему то по разному показывает на разном айпи, как установить часовой пояс МСК?
Вот скрипт

function timeGet(date, ints){
  
    let now = new Date().getTime();
    
    // Find the distance between now an the count down date
    let distance = ints - now;
     
    // Time calculations for days, hours, minutes and seconds
    let days = Math.floor(distance / (1000 * 60 * 60 * 24));
    let hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
    let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
    let seconds = Math.floor((distance % (1000 * 60)) / 1000);
    
    // Output the result in an element with id="demo"
     date.text(hours + ":" + minutes + ":" + seconds);
    
    // If the count down is over, write some text 
    if (distance < 0) {
        clearInterval(x);
        document.getElementById("demo").innerHTML = "EXPIRED";
    } else {
      setTimeout(function(){ timeGet(date, ints); }, 1000);
    }
  
  
}
  • Вопрос задан
  • 79 просмотров
Решения вопроса 1
v1t3man
@v1t3man
с помощью Date.UTC

new Date(Date.UTC(year, month, day, hour, minute, second));
Ответ написан
Пригласить эксперта
Ответы на вопрос 1
Если много с датами работаете попробуйте https://momentjs.com/
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы