How can the issue of getting the wrong calendar week result be avoided in PHP?

Issue: The wrong calendar week result in PHP can be avoided by using the correct format specifier for the week number, which is 'W' in PHP. This specifier ensures that the week number is calculated based on ISO-8601 standard, where the week starts on a Monday and the first week of the year is the one that contains the first Thursday. PHP code snippet:

$date = '2023-01-01'; // Example date
$weekNumber = date('W', strtotime($date));
echo "Week number for $date: $weekNumber";