Solved

current date+4 days

Posted on 2011-03-10
6
287 Views
Last Modified: 2012-06-27
current date+4 days
0
Comment
Question by:rgb192
[X]
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
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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

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!

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

734 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