DarrenReeder Posted December 8, 2009 Share Posted December 8, 2009 Hello.. On my site i have made my own 'mini' forums and im trying to make them order propaly so i original used the date() function save save the date into the mysql database like.. date(y-m-d) but that only saves the Year, month and day so it cant be orderd propaly...how can i make this save it so its Y-M-D, Hour,minute,Second ??? **P.S. im updated the original thread in the record everytime someone posts a reply and when the thread is made, and when i use the loop to display it all i make sure its order to the 'LastReply' DESC** Link to comment https://forums.phpfreaks.com/topic/184424-date-function-help/ Share on other sites More sharing options...
mattal999 Posted December 8, 2009 Share Posted December 8, 2009 Change the date field to a datetime type, then in your query when you insert a row: INSERT INTO table VALUES (NULL, '".$title."', NOW()) // The now part inserts the current date/time Link to comment https://forums.phpfreaks.com/topic/184424-date-function-help/#findComment-973523 Share on other sites More sharing options...
DarrenReeder Posted December 8, 2009 Author Share Posted December 8, 2009 hmm, you make your query different to mine, how do you change that for.. $date=date(y-m-d); $insert = mysql_query("UPDATE threads SET ReplayLast='$date' WHERE ID='$threadid'") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/184424-date-function-help/#findComment-973525 Share on other sites More sharing options...
mattal999 Posted December 8, 2009 Share Posted December 8, 2009 The query that you supplied simply updates the thread's views when somebody looks at the thread. My code is for when somebody creates a thread. Post your creation query and I will amend it accordingly. Oh, and to sort by date AND time, on your select query after the WHILE clauses add: ORDER BY datetime DESC // datetime being your field name for the date/time EDIT: $insert = mysql_query("UPDATE threads SET ReplayLast=NOW() WHERE ID='$threadid'") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/184424-date-function-help/#findComment-973529 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.