Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2010
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Add days to date function

    hi

    i have a problem with my program that needs to add days to a certain date
    For example..if i need to add 40 days to a given date..how do i do it? the following code doesn't work for me...

    Code:
    // current date
    $date = date("Y-m-d");
    
    
    $date = strtotime(date("Y-m-d", strtotime($date)) . " + 40 days");
    echo "Date is: $date";
    it just prints...Date is: 1277683200 on the screen. thanks in advance...

  • #2
    Regular Coder
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    118
    Thanks
    8
    Thanked 2 Times in 2 Posts
    40 days are 3456000 seconds, just + that.

  • #3
    New Coder
    Join Date
    Jan 2010
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    how exactly should i do it? i can't get it to work even if i add the seconds..

  • #4
    New Coder
    Join Date
    Jan 2010
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi...

    i just found an answer to my previos question

    the following code adds 40days to a given date...

    echo "Date +40days is".date('Y-m-d', strtotime("+40 days"));

    thanks to those who replied to my question....

  • #5
    Regular Coder
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    118
    Thanks
    8
    Thanked 2 Times in 2 Posts
    Sorry, I was really in a hurry when writing to this topic. Here's a way.

    PHP Code:
    <?php
    $date 
    date("D\m\Y");
    $date $date 3456000;
    echo 
    $date
    ?>


  •  

    Posting Permissions

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