Page 1 of 1

Select Content by date

Posted: Mon Jun 01, 2009 5:11 pm
by amsterdam
Hi,

I have made a form that users can add events. When i display all the events I am trying to order the events by the event date. More specifically I want to order the next upcoming event date that the user inputed.

For example todays date is 6-1-09 and there are events scheduled for 6-23-09, 6-3-09, and 7-12-09. The event should be order like: 6-3-09, 6-23-09, 7-12-09.


Also i would like select past event dates. Date that were schedule that have past the current date.

Any help would be greatly appreciated.

Re: Select Content by date

Posted: Mon Jun 01, 2009 6:00 pm
by mikemike
The issue is how you store the dates, the way I see it there are two main ways of storing dates:

1. As a MySQL timestamp (hh:mm:ss yyyy-mm-dd)
2. As a UNIX timestamp (seconds from epoch (jan 1st 1970): 1245678912)

I normally use option 2 but it's often a matter of preferrance. Both will allow you to use an ORDER BY statement in your queries.