Grow your CSS skills. Land your dream job.

Loop through dates

  • # March 9, 2013 at 5:30 am

    I’d like to make a _selection list of dates_ that a user could choose from. The date should start by the **Current date today** and ends **5 days after**. I just don’t know how to execute it inside a loop so I wouldn’t change the date over and over again. Thanks. Please help. ;(

    # March 9, 2013 at 7:19 am

    $date = new DateTime(); // Without argument: now
    $interval = new Dateinterval(“P1D”); // Period: 1 day
    for ($i = 0; $i < = 5; $i++) {
    echo $date->format(“Y-m-d”).”n”;
    $date->add($interval);
    }

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".