PHP if today is Saturday or Sunday

You can also use date('N') where Sat = 6 and Sun = 7

<?php
if(date('N') > 5) { 
    echo "Today is Saturday or Sunday.";
} else {
    echo "Today is not Saturday or Sunday.";
}
?>

You can simply do it using in_array() function

<?php
if(in_array(date('D'),['Sat','Sun'])) {
   echo "Today is Saturday or Sunday.";
} else {
   echo "Today is not Saturday or Sunday.";
}

The issue is, you have to check the condition individually.

Try this:

<?php
if(date('D') == 'Sat' || date('D') == 'Sun') { 
  echo "Today is Saturday or Sunday.";
} else {
  echo "Today is not Saturday or Sunday.";
}
?>

Explanation:

date() function with 'D' parameter will return the day like Sat, Sun etc

Output : Today is Saturday or Sunday.

Working code

date() parameters list

Tags:

Php