Go Back   WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
LinkBack Thread Tools
Old 09-28-2009, 12:22 PM   #1
The Wandering Businessman
War Room Member
 
Chris Ramsey's Avatar
 
Join Date: Jan 2008
Location: The Globe
Posts: 1,209
Thanks: 142
Thanked 755 Times in 196 Posts
Default 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.

Chris Ramsey is online now   Reply With Quote
Old 09-28-2009, 02:44 PM   #2
PHP Author and Programmer
War Room Member
 
Robert Plank's Avatar
 
Join Date: Jul 2002
Location: Turlock, CA, USA.
Posts: 4,024
Blog Entries: 82
Thanks: 28
Thanked 227 Times in 46 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
Contact Info
Send a message via ICQ to Robert Plank Send a message via AIM to Robert Plank Send a message via MSN to Robert Plank Send a message via Skype™ to Robert Plank
Default 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.

Robert Plank is offline   Reply With Quote
Old 09-28-2009, 09:00 PM   #3
Warrior Member
 
Join Date: Sep 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
Pro24 is offline   Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk

Tags
date or time, php, sorting

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -6. The time now is 02:08 AM.