Drongo_III Posted November 18, 2012 Share Posted November 18, 2012 Hi Guys Simple question but as I dont tend to work with dates much I figured I'd get some advice. I have a DB table and one of the fields is the 'date of publish' in the format 'YYYY-MM-DD' and based on whether the date is in the future or the past I need to display the row data. What I was wondering is whether a method as simple as the following is a viable method to determine whether the date from the db is in the future or not: strtotime() on date from database Get current time() use the php min function to determine if the date in the database is larger than current time - which would indicate it's in the future. Or is that too simplistic and stupid? The other option I am playing with is DateTime::diff but as I need to evaluate a large number of values in this way it seems a bit heavy. Any opinions on whether i am on the right track, and if so, which you'd advise? Thanks, Drongo Quote Link to comment https://forums.phpfreaks.com/topic/270885-simplest-way-to-evaluate-two-dates/ Share on other sites More sharing options...
Pikachu2000 Posted November 18, 2012 Share Posted November 18, 2012 WHERE date > CURDATE() Quote Link to comment https://forums.phpfreaks.com/topic/270885-simplest-way-to-evaluate-two-dates/#findComment-1393452 Share on other sites More sharing options...
Drongo_III Posted November 18, 2012 Author Share Posted November 18, 2012 Ha! See this is why I asked That's great. Thank you pik. WHERE date > CURDATE() Quote Link to comment https://forums.phpfreaks.com/topic/270885-simplest-way-to-evaluate-two-dates/#findComment-1393453 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.