What are some alternative methods to the mktime function in PHP 7, especially when dealing with date manipulation?

When dealing with date manipulation in PHP 7, an alternative method to the mktime function is to use the DateTime class. This class provides a more object-oriented approach to working with dates and times, making it easier to manipulate and format them.

// Using DateTime class for date manipulation
$date = new DateTime();
$date->setDate(2022, 12, 31);
$date->setTime(23, 59, 59);

echo $date->format('Y-m-d H:i:s'); // Output: 2022-12-31 23:59:59