Solved

current date+4 days

Posted on 2011-03-10
6
279 Views
Last Modified: 2012-06-27
current date+4 days
0
Comment
Question by:rgb192
  • 3
  • 2
6 Comments
 
LVL 15

Expert Comment

by:gplana
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.
 
<?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
 

Author Comment

by:rgb192
ID: 35097711
how do I call this function
0
 
LVL 15

Expert Comment

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

0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 15

Accepted Solution

by:
gplana earned 175 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');
0
 
LVL 34

Assisted Solution

by:Beverley Portlock
Beverley Portlock earned 175 total points
ID: 35098893
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
 

Author Closing Comment

by:rgb192
ID: 35099411
thanks
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

821 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