How to add days to date in PHP?

Discussion in 'PHP & Perl' started by undeterminederror, Jan 13, 2009.

  1. undeterminederror

    undeterminederror BANNED BANNED

    Joined:
    Mar 31, 2008
    Messages:
    630
    Likes Received:
    457
    i have a list of elements that i need to be added by date :

    2008-06-25 [xxxxxxxx]
    2008-06-26 [xxxxxxxx]
    2008-06-27 [xxxxxxxx]
    2008-06-28 [xxxxxxxx]
    2008-06-29 [xxxxxxxx]
    2008-06-30 [xxxxxxxx]
    2008-07-1 [xxxxxxxx]
    2008-07-2 [xxxxxxxx]
    ................

    the list is too long to add dates manually .

    i tried with :

    echo 'Next Day: '. date('Y-m-d', strtotime('+1 days')) ."\n";

    works just for next day...


    should be something like count ... $count++; print ( "(".$count." .......

    anyone please help ?
     
  2. raimis100

    raimis100 BANNED BANNED

    Joined:
    Jun 7, 2008
    Messages:
    125
    Likes Received:
    42
    Code:
    for ($I = 0; $I < 30; $I++) {
    
    echo 'Next Day: '. date('Y-m-d', strtotime("+$I days")) ."\n";
    
    }
    


    Try this
     
    • Thanks Thanks x 1
  3. undeterminederror

    undeterminederror BANNED BANNED

    Joined:
    Mar 31, 2008
    Messages:
    630
    Likes Received:
    457
    Thanks Raimis.
    worked with this:
    print ('Next Day: '. date('Y-m-d', strtotime("+$I days")) ."\n");
    $I++;