You can do it using strtotime
, with the parameter 'next sunday'
, take the example:
to write to the database
// formatei no formato que utilizo no banco, e complementei com o horário fixo
echo date("Y-m-d", strtotime('next sunday')) . ' 08:00:00';
Exit:
2016-08-14 08:00:00 // próximo domingo 08h (considerando que hj é 10/08/2016)
to generate the buttons
To check the status of the button:
I created a function that will check if it is to write the button enabled or disabled:
function checaLiberacao($dt_liberacao) {
$liberado = strtotime($dt_liberacao);
$agora = strtotime('now');
if ($liberado <= $agora) {
echo '';
} else {
echo 'botão desabilitado';
}
}
USE:
$dt_liberacao = '2016-08-14 08:00:00'; // substituir por método para trazer dados do banco
checaLiberacao($dt_liberacao);
Returns: disabled button
Another example:
$dt_liberacao = '2016-08-09 08:00:00'; // substituir por método para trazer dados do banco
checaLiberacao($dt_liberacao);
Returns:
button enabled
I hope I’ve helped!
+1 But it might be useful to insert the comparison as well: enable/disable button. To be more complete
– Miguel
Done, just replace the fixed date with the one you bring from the database and implement the method to generate the buttons.
– Allan Andrade
Vlw, you solved my problem!
– Thiago