How to check day of the week in PHP?

In this tutorial, we are going to see how to check day of the week in PHP.

1. Code:

    <?php 	
	function isCheckDayOfWeek($date, $dayOfWeek){
		$timestamp = strtotime($date);
		$day = date("l", $timestamp);
		$normalizedDay = strtolower($day);
		if ($normalizedDay == $dayOfWeek) {
			return true;
		} else {
			return false;
		}
	}
	
	$str = isCheckDayOfWeek("2022-06-17", "friday");	
	var_dump($str);
    ?> 

2. Example:

Input:

"2022-06-17", "friday";
"2022-06-20", "friday";

Output:

bool(true) 
bool(false)