Time zone in JS

Asked

Viewed 348 times

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 it not happen? Could I do it using a GMT/Time Zone? If so, how?

1 answer

1


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

  • I don’t have enough knowledge to accurately guide Fábil Miguel, but I believe it is possible with Javascript, using something like this -> http://help.exacttarget.com/pt-BR/Documentation/exacttarget/content/javascript_do_server/guide_syntax/core_library_server_side_javascript_functions/funcoes_javascript_do_servor_datetime/

  • I believe that this way will give a much greater work, and will continue without much effectiveness.

  • All right! I will choose to leave as it is. thanks.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.