Adrian
Adrian

Reputation: 39

PHP MySQL Disable a button if today is Sunday

Need some help on how to disable a button. Using HTML/PHP

If today is Sunday, disable the button.

<button>Disable Me</button>

Else If today is Weekdays, (from 8am to 5pm) the button is active. Otherwise, the button is disabled.

if(8am to 5pm){

<button>Active</button>

}else{
<button>Disable Me</button>

Upvotes: 0

Views: 224

Answers (1)

shadab.tughlaq
shadab.tughlaq

Reputation: 454

$current_date_array = getdate();

if($current_date_array['weekday'] == "Sunday" || $current_date_array['hours'] < 8 || $current_date_array['hours'] > 17){
    //disable the button
} else {
    //enable
}

This means

if(today is Sunday OR time less than 8 am OR time is greater than 5 pm))

Upvotes: 1

Related Questions