I have this multidimentional array :
[
{
"Id": 14,
"ClassDate": "2019-09-20T00:00:00",
"StartTime": "06:00:00"
},
{
"Id": 27,
"ClassDate": "2019-09-20T00:00:00",
"StartTime": "07:45:00"
},
{
"Id": 144,
"ClassDate": "2019-09-21T00:00:00",
"StartTime": "05:00:00"
},
{
"Id": 170,
"ClassDate": "2019-09-21T00:00:00",
"StartTime": "08:45:00"
},
]
I want to sort this array values by date and then same date values by time.
This is the code I have which sorts the values by only date
function cmp($a, $b) {
$a = strtotime($a['ClassDate']);
$b = strtotime($b['ClassDate']);
if ($a == $b) { return 0; }
return ($a < $b) ? -1 : 1;
} usort($result_array, "cmp");
Do anyone have a solution for this? I am sure I am the 1 millionth one to do this...