Date examples in phpCI:
Start time: 15:13:35 End time: 15:13:35
Requirement: segments are added based on days.
The fields displayed in the database are 3 segments, one data entry on the first, one data entry on the second, and one data entry on the third.
How to compile it?
Thank you for your answers.
Reply to discussion (solution)
$ Start_time = strtotime ("15:13:35"); $ end_time = strtotime ("15:13:35 "); // the following code indicates that the same year and month can be determined based on the year and month in different years. $ days = date ('D', $ end_time)-date ('D ', $ start_time) + 1; // 3 $ data = array (); for ($ I = 0; $ I <$ days; $ I ++) {// Other data corresponding to the date can be added here $ data [] ['date _ time'] = date ('Y-m-d H: I: S ', $ start_time + $ I * 86400);} var_dump ($ data);/* output: Array ([0] => Array ([date_time] => 15:13:35) [1] => Array ([date_time] => 15:13:35) [2] => Array ([date_time] => 15:13:35 ))*/
That's it.