Time zone in JS

2
$(function() {
    var d = new Date();
    var hora = d.getHours();
    if (_userdata["user_level"] > 0) {
        console.log("Você é da staff e pode acessar o fórum.");
    } else if (hora >= 22 || hora <= 7) { 
        $('body').html('<div class="forumfechado">Fórum atualmente fechado. Volte mais tarde.</div>');
    };
});

This code "closes" the webpage between 22 and 7. However, it takes the time of the PC and anyone who changes the time of the PC can access the webpage. How do I make sure this does not happen? Could you do it using a GMT / Time Zone? If so, how?

    
asked by anonymous 17.11.2015 / 01:52

1 answer

1

This is not possible with javascript, you need some language that runs on the server (php for example) to ensure the effectiveness of the lock.

    
17.11.2015 / 02:54