Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Loop through dates

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #43262
    ajnoguerra
    Participant

    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. ;(

    #127591
    ajnoguerra
    Participant

    $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)
  • The forum ‘Back End’ is closed to new topics and replies.