![]() | | ||||||||
| | #1 |
| The Wandering Businessman War Room Member Join Date: Jan 2008 Location: The Globe
Posts: 1,209
Thanks: 142
Thanked 755 Times in 196 Posts
|
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. |
| | |
| | |
| | #2 |
| PHP Author and Programmer War Room Member Join Date: Jul 2002 Location: Turlock, CA, USA.
Posts: 4,024
Blog Entries: 82 Thanks: 28
Thanked 227 Times in 46 Posts
|
Chris, Store the dates using the numeric date representation... only worry about converting to yyyy-mm-dd when you display the dates to viewers. |
| | |
| | |
| | #3 |
| Warrior Member Join Date: Sep 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
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. |
| | |
![]() |
|
| Tags |
| date or time, php, sorting |
| Thread Tools | |
| |
![]() |