phpBeginner06 Posted January 6, 2007 Share Posted January 6, 2007 I have a datatable in a web page that sorts in descending order. It sorts first by date (ie 01/06/2007) and then it sorts by time (ie 5:21 pm or 5:21 am). This worked great until I had a date of 01/06/2007 and a time of 5:35 am and a date of 01/06/2007 and a time of 5:23 pm. The datatable sorted the time numbers, but did not sort the "am" and "pm" values.So looks like this when it is sorted:[u]First Display[/u]01/06/20075:35 am[u]Second Display[/u]01/06/20075:23 pmMy question is; does anyone know a way to sort am/pm value of time (ie date, time, timezone desc)? Link to comment https://forums.phpfreaks.com/topic/33150-sort-am-pm/ Share on other sites More sharing options...
ToonMariner Posted January 6, 2007 Share Posted January 6, 2007 sounds like you are not using teh date/time field in your database - this would sort that for you. Link to comment https://forums.phpfreaks.com/topic/33150-sort-am-pm/#findComment-154507 Share on other sites More sharing options...
phpBeginner06 Posted January 6, 2007 Author Share Posted January 6, 2007 If I use date/time; my time keeps display "0000-00-00 00:00:00" as the default; even when I clear out the default field (I am using myPHPAdmin). I want it to sort by "date, time, am/pm"; but I also want to be able to display a time on the web page like: 5:35 am or 5:35 pm, not "0000-00-00 00:00:00".So how can I do this? Link to comment https://forums.phpfreaks.com/topic/33150-sort-am-pm/#findComment-154535 Share on other sites More sharing options...
ToonMariner Posted January 6, 2007 Share Posted January 6, 2007 use the date time - and always put a date time in it OR add teh date != '0000-00-00 00:00:00' in your query to filter out those records Link to comment https://forums.phpfreaks.com/topic/33150-sort-am-pm/#findComment-154545 Share on other sites More sharing options...
phpBeginner06 Posted January 7, 2007 Author Share Posted January 7, 2007 Is the anyway to trim or clip the ":00" of the end of a "0:00:00" (field marked as "TIME")? So that when it displays in a web page it will look like this:[quote]11:51[/quote] Link to comment https://forums.phpfreaks.com/topic/33150-sort-am-pm/#findComment-154796 Share on other sites More sharing options...
Jessica Posted January 7, 2007 Share Posted January 7, 2007 substr() Link to comment https://forums.phpfreaks.com/topic/33150-sort-am-pm/#findComment-154807 Share on other sites More sharing options...
trq Posted January 7, 2007 Share Posted January 7, 2007 [url=http://php.net/strtotime]strtotime[/url]. Link to comment https://forums.phpfreaks.com/topic/33150-sort-am-pm/#findComment-154810 Share on other sites More sharing options...
Jessica Posted January 7, 2007 Share Posted January 7, 2007 thorpe - then he'd still have to use date() on it... Link to comment https://forums.phpfreaks.com/topic/33150-sort-am-pm/#findComment-154812 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.