3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getLineChartPromedio($format = 'Y-m-d'){ $startDate = '2020-07-08'; //$this->input->post('startDate'); $endDate = '2020-07-12'; //$this->input->post('endDate'); // Declare an empty array $arraydias = array(); // Variable that store the date interval // of period 1 day $interval = new DateInterval('P1D'); $realEnd = new DateTime($endDate); $realEnd->add($interval); $period = new DatePeriod(new DateTime($startDate), $interval, $realEnd); // Use loop to store date into array foreach($period as $date) { $fecha = $date->format($format); $arraydias[] = $fecha; } $string = "'" . implode("','", $arraydias) . "'"; echo json_encode($string); } getLineChartPromedio();

preferences:
25.93 ms | 405 KiB | 5 Q