sort array by date using usort code example
Example 1: php array order by date
usort($array, function($a, $b) {
return new DateTime($a['datetime']) <=> new DateTime($b['datetime']);
});
Example 2: sort array by date
const sortedActivities = activities.sort((a, b) => b.date - a.date)