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.
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.
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.
This topic is now closed. New replies are no longer allowed.