Reputation: 35
I am using an html form to get a user inputted date. The structure of the date inputted is: MM/DD/YYYY. I then need to increment the total days by 196 in PHP. Right now, the data is being posted to a php file called Calculate.php. I was looking into altering the data using date (m d Y); in php, but my friend said that probably wont work. Any ideas? Thank you for your time and have a great day! ^_^
Upvotes: 1
Views: 303
Reputation: 101604
strtotime
. This will convert your MM/DD/YYYY format in to a numeric value you can then work with.strtotime
again to manipulate the date to add the days to it.strftime
to re-format it for display.e.g.
$d = '08/11/2011';
$dAsPOSIX = strtotime($d);
$dPlus196Days = strtotime('+196 day', $dAsPOSIX);
echo strftime('%m/%d/%Y',$dPlus196Days);
Upvotes: 2
Reputation: 52372
$input = $_POST['date'];
echo date('m d Y', strtotime('+196 days', strtotime($input));
Upvotes: 0