Re: Sorting times (SOLVED)
| From: | tedd | Date: | Sat, 14 Feb 2009 22:15:28 +0000 |
| Subject: | Re: Sorting times (SOLVED) | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-288273@lists.php.net to get a copy of this message | ||
At 4:15 PM -0500 2/14/09, John Corry wrote:
1. convert the string representation of times to timestamps using strtotime() 2. sort the timestamps 3. display the timestamps as strings using date('format', timestamp) Would that work? John Corry email: jcorry@gmail.comJohn: Bingo -- that worked! Thanks. tedd --- Here's the code. <?php // ====== returns a time array sorted function sortTime($in_times) { $time = array(); foreach ($in_times as $t) { $time [] = strtotime($t); } sort($time); $sort_time = array(); foreach ($time as $t) { $sort_time[] = date('g:ia', $t); } return $sort_time; } ?> -- ------- http://sperling.com http://ancientstones.com http://earthstones.com