lizzus
lizzus

Reputation: 13

Show text if current time is between 9:00pm and 10:30pm on friday

I am trying to show a text in a page only on Thursday between 9pm to 10pm.

At the moment I wrote this code:

if((date('N') == 4 && date('G') >= 21) || (date('N') == 4 && date('G') < 22)) {
    echo "Text";
}

but not work.

Upvotes: 0

Views: 22

Answers (1)

Jason K
Jason K

Reputation: 1381

The or was causing the problem. So it always echo out.

if(date('N') == 4 and ( date('G') >= 21 and date('G') < 22)) {
    echo "Text";
}

Upvotes: 2

Related Questions