[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


current date+4 days

Posted on 2011-03-10
Medium Priority
Last Modified: 2012-06-27
current date+4 days
Question by:rgb192
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 15

Expert Comment

ID: 35097635
This function allows the addition of day(s),month(s),year(s) to the original date while still preserving the Hours, minutes and seconds
You can also modify to add to hours, miuntes and even seconds.
function add_date($givendate,$day=0,$mth=0,$yr=0) {
      $cd = strtotime($givendate);
      $newdate = date('Y-m-d h:i:s', mktime(date('h',$cd),
    date('i',$cd), date('s',$cd), date('m',$cd)+$mth,
    date('d',$cd)+$day, date('Y',$cd)+$yr));
      return $newdate;


Author Comment

ID: 35097711
how do I call this function
LVL 15

Expert Comment

ID: 35097732
$newdate = add_date(curdate(),4)
echo format($newdate,'m/d/Y');

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 15

Accepted Solution

gplana earned 700 total points
ID: 35097745
sorry, there is a missing semi-colon (;) on my previou message. Please try this:

$newdate = add_date(curdate(),4)
echo format($newdate,'m/d/Y');
LVL 34

Assisted Solution

by:Beverley Portlock
Beverley Portlock earned 700 total points
ID: 35098893

$fourDaysHence = date("Y-m-d", strtotime("NOW +4 DAYS") );


$fourDaysHence = date("m/d/Y", strtotime("NOW +4 DAYS") );

See http://uk.php.net/manual/en/function.date.php for different ways to lay out the resulting date


Author Closing Comment

ID: 35099411

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question