ok so i have a time that i need to order by but i dont know how to make it order, in order by am then pm.

Ex: i have to events that i put in the calendar one for 6:00 am and one for 9 pm. I put order my time DESC but all it does is put the 9:00 pm first

How is the date entered in the database? Kind of hard to figure out what the problem might be without more info (an example).

not the date just the time. 1:00 am, 2:00 am, 3:00 am etc. exactly like that as text

That's going to be a pain in the butt. lol You're going to have to search the string to see if 'a' exists in it to sort it by AM or PM and then sort it by the numbers. (At least that's the only way I can think of doing it.)


It's be much easier if you just entered the time using 00 through 23 for the hours and then sort it by minutes using 00 through 59. Or just convert it all into minutes and mod it by 60.

well if it is a pain in the butt i got to get it done.

haha. i was just looking at that but i cant make sense of it right now

obviously it is that difficult. i understand the the time_format(time, '%I:%i%p'). but where do i get time from and how do i write the query in php.

this is new to me and i dont know how to do it. there is not much on google besides that post to help me along

can someone help me with this again. i never did figure it out. this is my query that i need to sort in time order with am/pm

SELECT * FROM eventcal WHERE company_id='$company_id' and email='$login_email' and eventDate='$today' ORDER BY eventDate DESC