Monday, 18 August 2014

How to take dates between two dates in php?

   $task_to_do = array();
   echo "
"; $s = strtotime("START_DATE"); $d = strtotime("END_DATE"); $dif = 86400; $i=$s; $x=0; while ($i <= $d) { $dat = date("Y-m-d 00:00:00",$i); $t_s = date("Y-m-d 00:00:00",strtotime($dat)); $t_e = date("Y-m-d 23:59:59",strtotime($dat)); $task_to_do[$x]["start_date"] = $t_s; $task_to_do[$x]["end_date"] = $t_e; $i = $i+$dif; $x++; } echo "
";
   print_r($task_to_do);

No comments:

Post a Comment