Block item for about 10 minutes

-1

I'm not going to post my code so I'm not ashamed, but does anyone have any idea how to block a div for some definite time? After clicking this div it disappears and after the set time it will appear again.

    
asked by anonymous 23.12.2017 / 02:24

1 answer

2

Here is a clean code and I did the way I understood in 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 ceil

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

    
23.12.2017 / 02:44