Last active
November 6, 2018 17:13
-
-
Save llucasshenrique/fce84eb6407cbc30a931e58381afb707 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$date1 = new DateTime('Mon, 15 Aug 05 15:52:01 +0000'); | |
$date2 = new DateTime('Mon, 15 Aug 05 09:52:01 +0000'); | |
$date3 = new DateTime('Mon, 15 Aug 05 10:32:01 +0000'); | |
$paraSerOrdenado = [ | |
'array1' => [ | |
'datareal' => $date1, | |
'datastr' => $date1->getTimestamp(), //timestamp é int | |
], | |
'array2' => [ | |
'datareal' => $date2, | |
'datastr' => $date2->getTimestamp(), | |
], | |
'array3' => [ | |
'datareal' => $date3, | |
'datastr' => $date3->getTimestamp(), | |
] | |
]; | |
uasort($paraSerOrdenado, function($a, $b) { | |
return (strcmp($a['datastr'], $b['datastr'])); | |
}); | |
var_dump($paraSerOrdenado); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment