可能的重复:
如何在 php 中为 unix 时间戳添加 24 小时?
如何将天数转换为unixtimestamp?
例如,如果用户在表单中输入 55(=55 天),我希望将 55 天添加到当前时间,然后将其存储在 unix 时间戳中。
算术time():
$input = (int) $_POST['days'];
$timestamp = time() + $input * 86400;
Run Code Online (Sandbox Code Playgroud)
或者也许使用strtotime():
$input = (int) $_POST['days'];
$timestamp = strtotime('+' . $input ' days');
Run Code Online (Sandbox Code Playgroud)