Split a string to tow Datetime objects
I have a string which is ACTUALLY STORING TIME 09:00-18:00, I want to get 2 DateTime. The time of the 18:00 returns an object and that of the 09:00 returns another object. I tried to use split, but IT does not WORK that’s why I NEED A solution.
// Get start time and end time separated by "-"
$split = preg_split('/[s-]+/', $line['intervention_hour']);
// Get hour number and minute separated by "h"
$start = preg_split('/[:]+/', $split);
$end = preg_split('/[:]+/', $split);