What potential pitfalls should be considered when using the mktime() function in PHP to calculate timestamps?

One potential pitfall when using the mktime() function in PHP to calculate timestamps is that it may return incorrect results when working with dates outside the range of Unix timestamps (before 1970 or after 2038). To avoid this issue, it is recommended to use the DateTime class in PHP, which provides better support for a wider range of dates and times.

// Using DateTime class to calculate timestamps
$date = new DateTime('2022-12-31');
$timestamp = $date->getTimestamp();
echo $timestamp;