almightyegg Posted October 1, 2007 Share Posted October 1, 2007 I tried ordering by timestamp and it was working fine until today (Oct 1st) and it is now appearing at the bottom. It is obviously ordering by day of month...how do I fix that?? Is there a way around it??? Quote Link to comment https://forums.phpfreaks.com/topic/71399-order-by-timestamp/ Share on other sites More sharing options...
BlueSkyIS Posted October 1, 2007 Share Posted October 1, 2007 code? timestamp is always a higher integer, so if you're actually sorting using timestamp it will alwasy work. Quote Link to comment https://forums.phpfreaks.com/topic/71399-order-by-timestamp/#findComment-359339 Share on other sites More sharing options...
almightyegg Posted October 1, 2007 Author Share Posted October 1, 2007 Hmmm...just realised the problem I think. Does it have to be in timestamp col?? This is my setup: $timestamp = date("d-m-Y H:i:s"); Quote Link to comment https://forums.phpfreaks.com/topic/71399-order-by-timestamp/#findComment-359342 Share on other sites More sharing options...
BlueSkyIS Posted October 1, 2007 Share Posted October 1, 2007 Does it have to be in timestamp col?? yes. otherwise i assume you're storing it as a string, which will sort as strings do. Quote Link to comment https://forums.phpfreaks.com/topic/71399-order-by-timestamp/#findComment-359344 Share on other sites More sharing options...
darkfreaks Posted October 1, 2007 Share Posted October 1, 2007 you need to save the timestamp to a time column in the database then order the SQL to sort everything by that time column Quote Link to comment https://forums.phpfreaks.com/topic/71399-order-by-timestamp/#findComment-359354 Share on other sites More sharing options...
iPixel Posted October 1, 2007 Share Posted October 1, 2007 Agree with darkfreaks set up a timestamp column and make it automatically enter CURRENT_TIMESTAMP() upon new entry... then you shouldnt have the smallest problem sorting it. Quote Link to comment https://forums.phpfreaks.com/topic/71399-order-by-timestamp/#findComment-359358 Share on other sites More sharing options...
BlueSkyIS Posted October 1, 2007 Share Posted October 1, 2007 NOTE: Timestamp and Time columns are very different. You need a Timestamp column, as you asked. Quote Link to comment https://forums.phpfreaks.com/topic/71399-order-by-timestamp/#findComment-359361 Share on other sites More sharing options...
darkfreaks Posted October 1, 2007 Share Posted October 1, 2007 yeah timestamp column you need as said above time columns are very different. just make sure you use CURENT_TIMESTAMP() to order it by in the SQL. Quote Link to comment https://forums.phpfreaks.com/topic/71399-order-by-timestamp/#findComment-359365 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.