bsamson Posted June 28, 2008 Share Posted June 28, 2008 Hey ALL! I know how to add days to the current date, <?php echo "15 Days from today is: ".date("m/d/Y", strtotime("+15 days"); ?> How do I calculate 15 days from today when the user inputs the date (i.e. Not today) example: 06/02/2008 + 15 days Thanks in advance! Quote Link to comment Share on other sites More sharing options...
br0ken Posted June 28, 2008 Share Posted June 28, 2008 You might have to change this slightly depending on the format you're using for dates. $date = "06282008"; // Todays date $month = substr($date, 0, 2); $day = substr($date, 2, 2); $year = substr($date, 4, 4); echo date("m/d/Y", mktime(1, 1, 1, $month, ($day+15), $year)); If this confuses you just read up on the mktime() PHP function and should be clear. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted June 28, 2008 Share Posted June 28, 2008 strtotime can do this as long as the existing date is in a format it understands. For your mm/dd/yyyy example - <?php echo "15 Days from 06/02/2008 is: ".date("m/d/Y", strtotime("06/02/2008 + 15 days")); ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.