Conor Mackel Conor Mackel - 2 months ago 6
PHP Question

manipulating date variables in php

Hi I am trying to manipulate date input from the user.
I am accessing an api that requires a start date and end date, Currently I have the user entering the start date and the end date but I would ideally like the user to be able to input just the start date and the end date automatically assigned 7days later, I am currently using this code to assign the start and end date, Is it possible to just add 7days to the start date and assign that as the end date?

<div class="search-form">
<form action= "" method = "GET">
<div class="form-field">
<input type="type" name="start" placeholder= "yyyy-mm-dd" value="<?php $startDate; ?>"/>

<form action= "" method ="GET">
<div class="form-field">
<input type ="type" name= "end" placeholder="yyyy-mm-dd" value ="<?php $endDate;?>"/>

<button type="submit">Submit</button>



Please try this, e.g

$date = "Mar 03, 2011";
$date = strtotime($date);
$date = strtotime("+7 day", $date);
echo date('M d, Y', $date);

Hope it will help you.