turkman Posted March 20, 2010 Share Posted March 20, 2010 i have a datetime colum in my mysql table and every time i enter a record i populate it with NOW(); if i do $v strtotime("-1 Hour"); then compare the two it doesn't work... i assume strtotime isnt comparable with a datetime filed? Is it comparable with a timestamp field? Quote Link to comment https://forums.phpfreaks.com/topic/195882-datetime-in-sql/ Share on other sites More sharing options...
trq Posted March 20, 2010 Share Posted March 20, 2010 The fact that strtotime returns a timestamp should give you a hint. Quote Link to comment https://forums.phpfreaks.com/topic/195882-datetime-in-sql/#findComment-1028920 Share on other sites More sharing options...
PFMaBiSmAd Posted March 20, 2010 Share Posted March 20, 2010 Is there some reason why you are not using any of the mysql date and time functions directly in your query to do this? In fact, what are you attempting to accomplish? It is almost always simpler and faster (php is a relatively slow parsed, tokenized, and interpreted language compared to the compiled code of a database engine) to let the database engine retrieve the rows you are interested in, in the order that you want them, and with each piece of data formatted the way you want it. Quote Link to comment https://forums.phpfreaks.com/topic/195882-datetime-in-sql/#findComment-1029014 Share on other sites More sharing options...
turkman Posted March 20, 2010 Author Share Posted March 20, 2010 i was giving the admin an option to show all options withing the last hour/day/week etc which he selects from a dropdown list. Quote Link to comment https://forums.phpfreaks.com/topic/195882-datetime-in-sql/#findComment-1029067 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.