-2

I am trying to export a certain number of days and setting it to the variable $max_future. Currently it is a set amount of days but I want the users input variable to be the number it has instead.

Currently it is set as:

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

I want something like:

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

Is this possible? I appreciate any help

Alex Tartan
  • 6,736
  • 10
  • 34
  • 45

3 Answers3

1

Try:

$max_future = date("Y-m-d", strtotime($today . "+" . $exportDays . " days"));
SScotti
  • 2,158
  • 4
  • 23
  • 41
  • This worked, thanks! I should have thought of doing this... still learning :) –  Mar 02 '16 at 18:52
0

Something like this :

<?php
$output = 9; // you can take this value from input.
$today = date("Y-m-d");
echo date('Y-m-d', strtotime($today. ' +'.$output. ' days'));
?>
Drudge Rajen
  • 7,584
  • 4
  • 23
  • 43
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'));
Davis
  • 856
  • 4
  • 11