Good day, I have a form which should only be available for example one day a week from 9 am to 1 pm, I am looking for an option to carry out this, I do not know if this is possible, they could guide me please.
Good day, I have a form which should only be available for example one day a week from 9 am to 1 pm, I am looking for an option to carry out this, I do not know if this is possible, they could guide me please.
<?php
//Sacas la hora (Recuerda que es la hora del servidor)
$hora = date('H');
//Haces un simple comparativo entre los rangos que quieres que este disponible
if( $hora >= 9 && $hora < 13 ){
echo '<button type="button">Enviar</button>';
}else{
echo '<button type="button" disabled>Enviar</button>';
}
?>
I left you the commented code, this can be done in a line with a ternary if it would confuse you more taking into account that you are a novice.
ANNEX SOLUTION
How it comments Shaz , the ideal would be not to show the button, so the else is over.
<?php
//Sacas la hora (Recuerda que es la hora del servidor)
$hora = date('H');
//Haces un simple comparativo entre los rangos que quieres que este disponible
if( $hora >= 9 && $hora < 13 ){
echo '<button type="button">Enviar</button>';
}
?>
I hope it serves you.