• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

current date+4 days

current date+4 days
0
rgb192
Asked:
rgb192
  • 3
  • 2
2 Solutions
 
gplanaCommented:
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.
 
<?php
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;
              }

?>
0
 
rgb192Author Commented:
how do I call this function
0
 
gplanaCommented:
$newdate = add_date(curdate(),4)
echo format($newdate,'m/d/Y');

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
gplanaCommented:
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');
0
 
Beverley PortlockCommented:
Or

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

or

$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

0
 
rgb192Author Commented:
thanks
0

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.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now