rem — 2012-03-09T05:28:59-05:00 — #1
I have hit a hard spot with sorting an array relative to current date. I am trying to order it in such way that first elements would be March (current month of this post), each sorted by day ascending order and so on, April would come next, then May, etc. If current month would be December, then December element would be on top followed by January, February, etc ...
Any advice would be very appreciated.
wonshikee — 2012-03-09T18:56:35-05:00 — #2
This is easily done during a query.
If it has to be done in PHP, I would convert it to timestamp, or even YYYYMMDD format works for sorting.
But the logic is the same. You cut off any date before the current month. Then sort it ASC. it will then start the array at March and on.
rem — 2012-03-10T00:47:19-05:00 — #3
Yes, you are right, this should work. I was so focused on the array that it just didn't came to me. Thank you wonshikee.