djandy14 Posted December 22, 2008 Share Posted December 22, 2008 Heyy, I've created an online booking system for my disco website, but am finding a number of clients misclick the year and end up booking a disco for August 2008 instead of August 2009, for example which causes all sorts of problems. I need to keep the current year for future bookings but was hoping i could add a script to my page that will check the entered date against the current date, if the entered date is in the past it will return with a false request denying the client and returning them to the initial page. Is this possible? And if so, could anyone help me out!!! =] Thank you!! Andy Link to comment https://forums.phpfreaks.com/topic/138019-help-is-it-possible-to-check-a-date-against-the-past/ Share on other sites More sharing options...
ILMV Posted December 22, 2008 Share Posted December 22, 2008 This code seems to be exactly what you want... http://uk.php.net/manual/en/function.date.php#86907 Link to comment https://forums.phpfreaks.com/topic/138019-help-is-it-possible-to-check-a-date-against-the-past/#findComment-721346 Share on other sites More sharing options...
ngreenwood6 Posted December 22, 2008 Share Posted December 22, 2008 depends on how you are storing the date in the database but basically you would want to do something like this(of course this is using a timestamp): <?php $todays_date = time(); \\time it is now $customer_picked_date = time()-1; \\just did that so you know it is less than the actual time //you can do an if statement and if it returns false show an error message if($todays_date > $customer_picked_date) { echo "That date has already passed"; } Link to comment https://forums.phpfreaks.com/topic/138019-help-is-it-possible-to-check-a-date-against-the-past/#findComment-721387 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.