G
G
generate2020-10-07 17:19:19
JavaScript
generate, 2020-10-07 17:19:19

How to set the time zone MSK?

From the base I get the time and the site should have a timer, for some reason it shows differently on different ip, how to set the time zone MSC?
Here is the script

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);
    }
  
  
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
v1t3man, 2020-10-07
@generate

using Date.UTC

new Date(Date.UTC(year, month, day, hour, minute, second));

V
Vladimir, 2020-10-07
@Casufi

If you work with dates a lot, try https://momentjs.com/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question