Page 1 of 1

Adding days to a date

Posted: Fri Feb 15, 2008 4:45 pm
by ewg426
I have a variable, $IssuedDate that is in m/d/Y format. (The users selects the issued date from a pop-up calender). I need to add 7 days to that date as a new variable, $DateDue. I'm not sure how to do that. Note it is not necessary to verify if any of the dates, issued or due, fall on a Saturday, Sunday or holiday and they are allowed to pick an issue date in the past, even if that results in the due date being in the past.

Code: Select all

<INPUT maxLength=10 name=IssueDate size=10 readonly = yes value=
                <?
                    if (isset($_POST['IssueDate'])) {
                        echo date("m/d/Y",strtotime($_POST['IssueDate']));
                    } else {
                        echo date("m/d/Y");
                    }
                ?>
On a different form is where the variables are used.

Code: Select all

$IssueDate = ($_POST['IssueDate']);  
Thanks in advance

Re: Adding days to a date

Posted: Fri Feb 15, 2008 7:34 pm
by Christopher
strtotime() returns a Unix timestamp, which is in seconds since 1/1/1970. To add seven days you would add 60 * 60 * 24 * 2 seconds.