Adding days to a date

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ewg426
Forum Newbie
Posts: 1
Joined: Fri Feb 15, 2008 4:31 pm

Adding days to a date

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Adding days to a date

Post 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.
(#10850)
Post Reply