List upcoming events, ordered by date in a custom field

That is proper alpha-numerical order. If your dates are stored human-like as you have them posted in your question, that it is the best you get. It appears that that is the case. That is, if your dates are stored as “07-April-2013”, “18 -April-2013”, ect., in the database and you sort them, you are going to get that order. That is how alpha-numeric sorting works.

What you want is human-calendar order, which is neither numerical nor alphabetical, except in in one circumstance. If you store dates as YYYY-MM-DD, and sort numerically you will get an order matching human-calendar order. Another option is to store the dates in UNIX-time. I’d recommend UNIX time because date manipulation in PHP pretty much always means converting to UNIX time first anyway.

Your problem here is that you are storing data in a format that is always going to cause you trouble.

I can’t really point you to the right code edits without seeing the code you already have.

Similar question, possibly a duplicate: order post my meta value m/d/y format with year as included value

Leave a Comment