bschultz Posted April 9, 2008 Share Posted April 9, 2008 I have a calendar script that I downloaded, and I like it, but it sorts things out by the $starttime which is in this format 2007-08-26 15:00:00 The reason I want this fixed is that if you have an event that happens every Monday, it will "order by" the date...then the time. So, an event for 3pm (that happens every Monday) will show up before an event at 9am for just that Monday. I'm trying to adjust this code to strip out the date part of the variable $query = 'SELECT * FROM '.SQL_PREFIX."events\n" more code here ."ORDER BY starttime"; Here's what I tried... $stime = date_format(starttime, 'H:i:s'); $query = 'SELECT * FROM '.SQL_PREFIX."events\n" more code here ."ORDER BY sttime"; Here's the error I'm getting Warning: date_format() expects parameter 1 to be DateTime, string given in calendar/includes/calendar.php on line 286 Any idea where I'm going wrong? Thanks. Brian Quote Link to comment Share on other sites More sharing options...
fenway Posted April 9, 2008 Share Posted April 9, 2008 Why not use MySQL's DATE_FORMAT() function? Quote Link to comment Share on other sites More sharing options...
gluck Posted April 9, 2008 Share Posted April 9, 2008 use this instead ."ORDER BY date_format(starttime, 'H:i:s') "; Quote Link to comment Share on other sites More sharing options...
bschultz Posted April 9, 2008 Author Share Posted April 9, 2008 Thanks, gluck and fenway... ."ORDER BY DATE_FORMAT(starttime, '%T')"; did the trick. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.