2016-03-02 61 views
-2

我想输出一定天数并将其设置为变量$ max_future。目前这是一个固定的天数,但我希望用户输入变量是它所具有的数字。设置strtotime添加一个变量为天数

目前,它被设置为:

$max_future = date("Y-m-d", strtotime($today . "+6 days")); 

我想是这样的:

$exportDays = '9'; //(or whatever the user input was) 
$max_future = date("Y-m-d", strtotime($today . "+$exportDays days")); 

这可能吗?我感谢所有帮助

+1

你有发布问题之前尝试过吗? – Armen

回答

1

尝试:

$max_future = date("Y-m-d", strtotime($today . "+" . $exportDays . " days")); 
+0

这工作,谢谢!我应该想到这样做...仍在学习:) – LeeBronwin

0

事情是这样的:

<?php 
$output = 9; // you can take this value from input. 
$today = date("Y-m-d"); 
echo date('Y-m-d', strtotime($today. ' +'.$output. ' days')); 
?> 
0
<?php 
    $exportDays = $_REQUEST['exportDays']; // or however you want to get it from user input 
    $max_date = date('Y-m-d', strtotime(date('Y-m-d') . ' +' . $exportDays . ' days'));