What potential issues could arise when adding a specific number of weeks to a date in PHP?
When adding a specific number of weeks to a date in PHP, one potential issue that could arise is not accounting for leap years. This can result in the calculated date being off by one day. To solve this issue, you can use the DateTime class in PHP, which handles leap years and other date calculations accurately.
$date = new DateTime('2022-01-01');
$weeks_to_add = 2;
$date->modify('+' . ($weeks_to_add * 7) . ' days');
echo $date->format('Y-m-d');