Lock element for about 10 minutes

Asked

Viewed 57 times

-1

I’m not going to post my code so I don’t embarrass myself, but does anyone have any idea how to block a div for a set amount of time ? After clicking this div it disappears and after the set time it will appear again.

  • Put the code Will. It will be easier to help you.

1 answer

1

Here’s a clean code and I did it the way I understood your question:

<?php

//Salva esse tempo na tabela, você pode alterar +10 pra qualquer outro valor
$tempoAtual = strtotime('+10 minutes');

//Onde $tempoDB é o $tempoAtual que foi salvo na DB
$timer = ceil(($tempoDB - time()) / 60);

//Se o tempo guardado na DB ainda for maior que o tempo atual, conteúdo ficará bloqueado
if ($tempoDB > time()) {
    //bloqueado
}

See reference to Ceil

Note: The explanation is in the comments of each line made in the code. And the $timer it’s just formatting, from the time to not get that lot of numbers, it returns only the minutes decaying.

  • 1

    Opa worked. I even showed a message saying how long it can come back and see the div again

Browser other questions tagged

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