How can PHP developers ensure that date calculations result in the desired date, without automatically adjusting to the next valid date?

When performing date calculations in PHP, developers can ensure that the result is the desired date by using the DateTime class and setting the timezone to UTC. This prevents PHP from automatically adjusting dates to the next valid date due to daylight saving time or other timezone-related issues. By using UTC, developers can accurately manipulate dates without unexpected changes.

$date = new DateTime('2022-02-28', new DateTimeZone('UTC'));
$date->modify('+1 day');
echo $date->format('Y-m-d'); // Output: 2022-03-01