I'm trying to sort a multidimensional array by date ASC but i'm having troubles with... so i would like to ask you guys and girls why this happens?
my code is (Run at: Codepad example ):
$data = array (
array (
'date' => '2016-03-11 12:10:17',
'type' => '1'
),
array (
'date' => '2016-03-12 07:16:25',
'type' => '1'
),
array (
'date' => '2016-03-12 07:18:07',
'type' => '2'
),
array (
'date' => '2016-03-09 14:57:42',
'type' => '2'
),
array (
'date' => '2016-02-22 10:39:39',
'type' => '1'
)
);
usort($data, function($a, $b) {
return $a['date'] - $b['date'];
});
echo '<pre>';
var_dump($data);
The issue is that the sorting is not good, i mean it need to be from February to March and is not doing this and i can't find why.
Any help is very appreciated !.