Clarkie Posted March 16, 2012 Share Posted March 16, 2012 Hey, I'm using a script which allows you to click on a calendar to select the date to submit to the database. The date is submitted like this: 2014-02-08 Is there a really simple way to prevent rows showing if the date is in the past? Something like this: if($currentdate < 2014-02-08 || $currentdate == 2014-02-08) { } Thanks very much, Jack Quote Link to comment https://forums.phpfreaks.com/topic/259091-only-display-if-date-is-after-current-date-date-yyyy-mm-dd/ Share on other sites More sharing options...
samshel Posted March 16, 2012 Share Posted March 16, 2012 Check strtotime function. It converts a date into Unix timestamp. You can convert both current date and date to compare in unix timestamp [which is in seconds] and do a <= comparison. Quote Link to comment https://forums.phpfreaks.com/topic/259091-only-display-if-date-is-after-current-date-date-yyyy-mm-dd/#findComment-1328283 Share on other sites More sharing options...
Pikachu2000 Posted March 16, 2012 Share Posted March 16, 2012 Your question isn't very clear, but maybe something like this is what you mean? SELECT field FROM table WHERE date >= CURDATE() Quote Link to comment https://forums.phpfreaks.com/topic/259091-only-display-if-date-is-after-current-date-date-yyyy-mm-dd/#findComment-1328286 Share on other sites More sharing options...
Clarkie Posted March 16, 2012 Author Share Posted March 16, 2012 Check strtotime function. It converts a date into Unix timestamp. You can convert both current date and date to compare in unix timestamp [which is in seconds] and do a <= comparison. Thanks that's exactly what I need! Your question isn't very clear, but maybe something like this is what you mean? SELECT field FROM table WHERE date >= CURDATE() Thanks to you also I'll use this to actually get the right rows from the db. Quote Link to comment https://forums.phpfreaks.com/topic/259091-only-display-if-date-is-after-current-date-date-yyyy-mm-dd/#findComment-1328296 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.