I have user defined function sort which sorts by date. It works fine for the same year and does not work when the year changes. This an example of the dates that is sorted by the function:
01/02/2013
01/03/2013
12/12/2012
function mysort($a,$b) {
return $a['date']>$b['date'];
}
usort($arr,"mysort");
This is an old application which uses php4. Is there a way where I can compare dates directly?
Use strtotime.
function mysort($a,$b) {
return strtotime($a['date'])>strtotime($b['date']);
}