$date = new DateTime('2021-07-15'); $date->setDay(25); echo $date->format('Y-m-d'); // Output: 2021-07-25
$date = '2021-07-15'; $newDate = date('Y-m-d', strtotime($date . ' + 10 days')); echo $newDate; // Output: 2021-07-25In this example, we start with a string date '2021-07-15'. We use the strtotime function to add 10 days to the date and get a new date. Finally, we format the new date using the date function and get the output '2021-07-25'. Package/Library: This method is a part of the PHP DateTime class which is a built-in library in PHP. Therefore, no additional package or library is required.