![]() |
Sorting Date/Time In PHP Hey Warriors, I'm looking for a way to sort dates and times with PHP. Currently I'm using timestamps, but I'm really having a hard time wrapping my head around how I'm trying to do it. What I'm looking to do is check for dates between (date a) and (date b) and add 1 to a variable every time one is found. In theory this is easy, but I'm having a hard time with this today for some reason. So, how would you recommend sorting yyyy-mm-dd hh:mm:ss? Of course, i'm open to using another format, if it's easier to sort through. |
Re: Sorting Date/Time In PHP Chris, Store the dates using the numeric date representation... only worry about converting to yyyy-mm-dd when you display the dates to viewers. |
Re: Sorting Date/Time In PHP If you strip yyyy-mm-dd mm:ss to this: YYYYmmddmmSS then you can use the built in php sorting, compare functions. Just make sure you use the date field with leading 0!, otherwise it will not work. For example, in Day use the "d" as that represents a numerical value of the day with leading 0, from 0-31. |
| All times are GMT -6. The time now is 02:57 PM. |