How can the DateTime class in PHP simplify date manipulation tasks compared to traditional methods?

When working with dates and times in PHP, the DateTime class simplifies date manipulation tasks by providing a more object-oriented approach compared to traditional methods like using functions such as strtotime() and date(). The DateTime class offers a wide range of methods for manipulating dates, calculating intervals, formatting dates, and more, making it easier to work with dates and times in PHP.

// Create a new DateTime object
$date = new DateTime('2022-01-01');

// Add 1 day to the date
$date->modify('+1 day');

// Format the date in a specific format
echo $date->format('Y-m-d');