I have this kind of string 09:00-18:00, I want to get 2 \DateTime. The time of the right part returns an object and that of the left part returns another object.
I tried to use split, but the my solution does not seems great that's why I'm asking for another solution.
This is my 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[0]);
$end = \preg_split('/[:]+/', $split[1]);
Any help would be appreciated.