tags:

views:

45

answers:

3

I'm working on WordPress theme which has some custom functionality which includes the ability to add "events" that include a start and/or end date in string format.

I'm wondering what the best method would be to parse these date strings in order to figure out which event should be shown in what order?

Here's an example of the date strings associated with each event:

  1. Some event: 07/23/2010
  2. Some other event: 08/03/2010
  3. Another event: 09/10/2010 - 09/12/2010
  4. Last event: 11/12/2010

Sorry if this question shows my utter n00bness.

A: 

Drop the end date from anything that has it, so you're just dealing with a single date per event. Re-order your dates so they are YYYYMMDD - then you can just sort numerically.

Pickle
A: 

Use the following

select * from mytable order by STR_TO_DATE(mydate,'%m/%d/%Y')

You can append DESC at the end if you want the dates in descending order

ubuntuguy
A: 

The strtotime() function can parse string dates into a Unix timestamp. Use the timestamps to sort the events.

Kwebble
This seems to be the way to go... Thanks.
Josh