SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast MarkW78's Avatar
    Join Date
    Mar 2001
    Location
    Wellington, Ohio
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi everyone! I'm still trying to learn the basics of PHP, so I have a fairly simple question (I think).

    For a project I'm working on, I need to take the current date and add days to it. For instance, I want the date stamped to be 7 days after the actual date.

    I got the actual date fine, but haven't found how to add days to it. Thanks for your help!!!

    Mark Wright
    Wrightsites.com

  2. #2
    AdSpeed.com Son Nguyen's Avatar
    Join Date
    Aug 2000
    Location
    Silicon Valley
    Posts
    2,241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Welcome to SitePoint! Hope you find this forums helpful and see you around.
    Here is an example for your problem:
    Code:
    $today = date("d",time());
    $next7day = date("d",time()+7*86400);
    - Son Nguyen
    AdSpeed.com - Ad Serving and Ad Management Made Easy

  3. #3
    SitePoint Enthusiast MarkW78's Avatar
    Join Date
    Mar 2001
    Location
    Wellington, Ohio
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the warm welcome and for helping me out on this.

    I got it to work, then realized that seven days from now is next month but the month didn't change. But once you helped me out with the days, getting the months and years to change was not difficult.

    Thanks again for your help!

    Mark

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure if you looked at mktime() as it will change the moths and years for you.

    Code:
    $today = date("d",time());
    $next7day = date("d",mktime(0,0,0,date("m"), date("d") + 7, date("Y")));
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Enthusiast MarkW78's Avatar
    Join Date
    Mar 2001
    Location
    Wellington, Ohio
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks,

    That shortens the code that I was using.

    Thank you both for your help!

    Mark Wright


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •