PHP

HOW TO CREATE A DATE RANGE IN PHP

START & END DATE $start = new DateTime("2020-01-01"); $end = new DateTime("2020-03-02");

DAILY INTERVAL $interval = new DateInterval("P1D"); $range = new DatePeriod($start, $interval, $end); foreach ($range as $date) { echo $date->format("Y-m-d"); }

DATE-TIME OBJECT

01

START & END DATE $start = strtotime("2020-01-01"); $end = strtotime("2020-03-02");

DAILY INTERVAL for ($i=$start; $i<=$end; $i+=86400) { echo date("Y-m-d", $i); }

UNIX TIMESTAMP RANGE

02