Cases:
Start time: 2014-10-01 15:13:35 end time: 2014-10-03 15:13:35
Requirements: When added, segments are based on days.
The fields displayed in the database are 3 paragraphs, one data for number 1th, one data for number 2nd, and one for number 3rd.
How to write?
Ask for answers, thank you.
Reply to discussion (solution)
$start _time = Strtotime ("2014-10-01 15:13:35"), $end _time = Strtotime ("2014-10-03 15:13:35");//The following code presupposes the same month If not the same year different months plus the year and month judgement can be $days = date (' d ', $end _time)-date (' d ', $start _time) + 1; 3$data = Array (); for ($i = 0; $i < $days; $i + +) { //Here you can add additional data for the corresponding date $data [] [' date_time '] = Date (' y-m-d h:i : S ', $start _time + $i * 86400); }var_dump ($data);/* output is as follows: Array ( [0] = = Array ( [date_time] = 2014-10-01 15:13:35 ) [1] =& Gt Array ( [date_time] = 2014-10-02 15:13:35 ) [2] = = Array ( [date_time] + = 2014-10-03 15:13:35 )) */
That's it