Are there any potential pitfalls or limitations when using the mktime function to manipulate dates and times in PHP?
One potential limitation of using the mktime function in PHP is that it may not handle dates outside the range of Unix timestamps (i.e., before 1970 or after 2038) correctly. To work around this limitation, you can use the DateTime class, which provides more flexibility and handles a wider range of dates.
// Example of using DateTime class to manipulate dates and times
$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