How can the DateTime class in PHP help overcome the limitation of strtotime for timestamp generation?

The strtotime function in PHP has limitations when it comes to generating timestamps, especially when dealing with dates that are outside the Unix timestamp range. To overcome this limitation, we can use the DateTime class in PHP, which provides a more robust and flexible way to work with dates and times.

$date = '2030-12-31 23:59:59';
$datetime = new DateTime($date);
$timestamp = $datetime->getTimestamp();
echo $timestamp;