What are the potential pitfalls when using the format() method with DateInterval objects in PHP?

When using the format() method with DateInterval objects in PHP, one potential pitfall is that the format() method expects a DateTime object, not a DateInterval object. To solve this issue, you can add the DateInterval to a DateTime object and then use the format() method on the DateTime object.

$date = new DateTime();
$interval = new DateInterval('P1D');
$date->add($interval);
echo $date->format('Y-m-d');