使用if语句来确定周末

So I've got a table display of a calendar. I need to use PHP to evalute each row and if the row is on a Saturday or Sunday then set to a specific CSS class that will highlight the row as red.

if (isset($_POST['date'])) {    
    //store passed data from date to variables
    $startdate = date('Y-m-d', strtotime($_POST['date']));
    $holdstart = $startdate;
    $enddate = date('Y-m-t', strtotime($_POST['date']));
} else {
    // Nothing passed use current month
    $startdate = date('Y-m-d');
    $holdstart = $startdate;
    $enddate = date('Y-m-t');
};

The above is the PHP code I use in order to produce the table. The code below is the code used to loop through the days in the calendar that is selected:

//loops through each day of the month
while ($startdate != $enddate) {
    $startdate = date('Y-m-d', strtotime($startdate . ' +1 day'));
    $friendlymonth = date('D d M Y', strtotime($startdate));
    $dates[] = $startdate;
}

I know that what I'm looking for is an if condition however I don't know how to exactly specify the date and evaluate a condition based on if the date is a Saturday or a Sunday. Thanks for reading.

date('N', $timestamp) will return numeric representation of the day of the week (1-7).

Found the solution:

<?php if(date('w', strtotime($startdate)) == 6 || date('w', strtotime($startdate)) == 0) { echo 'danger'; }?>

For anyone that doesn't know $startdate is the variable where my date is stored in. If you see there where I've evaluate the condition to the values 6 and 0. Its because 6 to PHP is Saturday, 0 is Sunday. And the it starts from 1 = Monday, ans so forth. Feel free to chime in if I've added anything wrong.