How to Iterate or loop Between two Dates

Solution :  Sometimes we have need to iterate loop between two dates , example we have to update data or insert data in database between two dates. In php we can easily iterate loop between date range by using date function of php datetime, dateperiod etc.

HTML CODE :

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

PHP CODE :  

$begin = new DateTime($this->input->post('from'));

 $end = new DateTime($this->input->post('to'));

  $daterange = new DatePeriod($begin, new DateInterval('P1D'), $end);

    foreach($daterange as $date)

                                 {

         echo $date->format("Y-m-d") . "<br?>";

         }

?>

Trending Courses

CodeIgniter

Regular : 45 Days

Fastrack : 20 Days

Crash : 10 Days

Advance Digital Marketing

Regular : 6 Months

Fastrack : 3 Months

Crash : 2 Months

React JS

Regular : 45 Days

Fastrack : 20 Days

Crash : 7 Days

Laravel

Regular : 45 Days

Fastrack : 20 Days

Crash : 10 Days

Front End Developer

Regular : 7 Month

Fastrack : 4 Month

Crash : 2 Month

Request a Demo