note 25877 rejected from function.strtotime by nicos

From: Date: Wed, 09 Oct 2002 21:17:33 +0000
Subject: note 25877 rejected from function.strtotime by nicos
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-37869@lists.php.net to get a copy of this message
I had trouble with the above examples using this function to sort a MYSQL array and found that usort was a better choice. The below example sorts a text column which may contain a date using the strtotime function. function sortbyorderdate($a, $b) { if (empty($a["order_date"])) return -1; if (empty($b["order_date"])) return 1; return strcmp(strtotime($a["order_date"]), strtotime($b["order_date"])); } while ($rows[] = mysql_fetch_array($result)) {} usort($rows, "sortbyorderdate");

« previous php.notes (#37869) next »