Markota Posted February 1, 2011 Share Posted February 1, 2011 Hello! I want to sort the posts in my Guestbook by "DESC Date". The date entry format is: date("j F, Y, H:i ") With this string: $sql="SELECT * FROM $tbl_name oRDER BY datetime DESC "; i can sort it just by the number of the day. How could i sort it by the whole date? Thanks, Mark Quote Link to comment https://forums.phpfreaks.com/topic/226355-desc-sorting-by-dateh/ Share on other sites More sharing options...
Pikachu2000 Posted February 1, 2011 Share Posted February 1, 2011 You need to store date and time data in the proper YYYY-MM-DD HH:MM:SS format if you don't want this headache every time you try to manipulate it or use it. Quote Link to comment https://forums.phpfreaks.com/topic/226355-desc-sorting-by-dateh/#findComment-1168355 Share on other sites More sharing options...
Markota Posted February 1, 2011 Author Share Posted February 1, 2011 Isnt there any solution to solve it with my ("j F, Y, H:i ") format ? :/ Quote Link to comment https://forums.phpfreaks.com/topic/226355-desc-sorting-by-dateh/#findComment-1168357 Share on other sites More sharing options...
fenway Posted February 13, 2011 Share Posted February 13, 2011 Sure... STR_TO_DATE(). Quote Link to comment https://forums.phpfreaks.com/topic/226355-desc-sorting-by-dateh/#findComment-1173570 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.