PHP - 从现在起X小时后获取时间戳[重复]

This question already has an answer here:

I'd like to take a number of hours imputed in a text box and get a timestamp back so I can create a countdown timer.

The countdown is fine so ignore how that is done etc. But whats the best way to get a timestamp '48' hours from now. For example user has entered 48?

</div>
$hours = 48;
$timestamp = (new DateTime())->modify("+{$hours} hours")->format('U');

You can create a timestamp like this:

<?php
strtotime(date('d-m-Y H:i:s') . "+ 48 hours");
?>

Your looking for strtotime. For example, you can just use strtotime('+48 hours'), and it will return a unix timestamp for that time.