How can PHP be used to calculate the day of the week and calendar week from a given date?
To calculate the day of the week and calendar week from a given date in PHP, you can use the `DateTime` class along with the `format` method to extract the day of the week and `W` format character to get the calendar week.
$date = '2022-01-15';
$dateTime = new DateTime($date);
$dayOfWeek = $dateTime->format('l');
$calendarWeek = $dateTime->format('W');
echo "Day of the week: $dayOfWeek\n";
echo "Calendar week: $calendarWeek\n";