lJesterl Posted April 18, 2008 Share Posted April 18, 2008 I have a script where I check dates to see if they exist in a table. If they exist then there not available. I thought I had everything working untill I noticed a problem. I use the following portion of code $today=date("m/d/Y"); $oneweek = date('m/d/Y', strtotime("$today +7 days")); if($ADate < $oneweek){ $error="Your arrival date must be atleast 1 week from today's date."; } if($ADate < $today){ $error="Your arrival date can not be before today's date."; } $ADate is the date they choose on the previouse page. It is in the DD/MM/YYY format. For example 07/07/2008 I get the following errors. Everything else works and everything works if they pick 2008 or 2009 except for these 2 checks. If they pick 08/01/2009 it tells them it can not be before todays date becase 2008 is less than 2009 and if I take that part out it says your arrival date must be a week away because 2008 is less then 2009. How can I properly do these checks to do $ADate < $today and also $ADate is < $oneweek if its 2008 or 2009. Link to comment https://forums.phpfreaks.com/topic/101770-php-calender-help/ Share on other sites More sharing options...
Caesar Posted April 18, 2008 Share Posted April 18, 2008 Compare them as timestamps. Don't compare them after they've been formatted. Link to comment https://forums.phpfreaks.com/topic/101770-php-calender-help/#findComment-520714 Share on other sites More sharing options...
lJesterl Posted April 18, 2008 Author Share Posted April 18, 2008 Would you be willing to elaborate a little bit? [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/101770-php-calender-help/#findComment-520717 Share on other sites More sharing options...
Caesar Posted April 18, 2008 Share Posted April 18, 2008 <?php if(strtotime($ADate) < strtotime($oneweek)) //Then do the Dew ?> Link to comment https://forums.phpfreaks.com/topic/101770-php-calender-help/#findComment-520722 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.