CanMan2004 Posted January 29, 2007 Share Posted January 29, 2007 Hi allI currently have a support form which allows people to select a contact date, this is done with 3 drop down selection boxesDayMonthYearI want to stop people selecting a date which is on a weekend or more than 1 month away and also stop them selecting a date which is closer than 3 days away.So for example, if it was the 5th June 2007, then they wouldnt be able to select the 5th, 6th or 7th of June (as its closer than 3 days away), they would also only be able to select up to the 5th July and not be able to select a weekend.Is this easy to do and is there a script I could modify and use? I have hunted high and low, without luck.Any help would be aceThanks in advanceEd Quote Link to comment https://forums.phpfreaks.com/topic/36182-php-date/ Share on other sites More sharing options...
ted_chou12 Posted January 29, 2007 Share Posted January 29, 2007 organise your time to "YYYY-MM-DD"then use the code below:[code]if ((strtotime($date) - strtotime("now")) <= 259200) {echo "too close, please select more than three days away!";}//259200 is the number of seconds in three daysif ((strtotime($date) - strtotime("now")) > 2592000) {echo "too late, please select more than a month away!";}//2592000 is the number of seconds in a month[/code]I think this should work, tell me if it does or doesnt, give me some time for the weekend one.Ted Quote Link to comment https://forums.phpfreaks.com/topic/36182-php-date/#findComment-171829 Share on other sites More sharing options...
HuggieBear Posted January 29, 2007 Share Posted January 29, 2007 You could create a little function to do this using the strtotime(), date() and mktime() functions.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/36182-php-date/#findComment-171834 Share on other sites More sharing options...
CanMan2004 Posted January 29, 2007 Author Share Posted January 29, 2007 Yes, it works great, thanks Quote Link to comment https://forums.phpfreaks.com/topic/36182-php-date/#findComment-171835 Share on other sites More sharing options...
ted_chou12 Posted January 29, 2007 Share Posted January 29, 2007 here:[code]$date = strtotime($date);$date = date('D', $date);if ($date == "Sat" or $date == "Sun") {echo "We need to rest for the weekends!";}[/code]hope that works.Ted Quote Link to comment https://forums.phpfreaks.com/topic/36182-php-date/#findComment-171837 Share on other sites More sharing options...
ted_chou12 Posted January 29, 2007 Share Posted January 29, 2007 btw, yeap, i noticed, there are lots of strtotime(), how can you make this into a function? Quote Link to comment https://forums.phpfreaks.com/topic/36182-php-date/#findComment-171841 Share on other sites More sharing options...
HuggieBear Posted January 29, 2007 Share Posted January 29, 2007 I'll see if I can create you a nice little function...Huggie Quote Link to comment https://forums.phpfreaks.com/topic/36182-php-date/#findComment-171847 Share on other sites More sharing options...
ted_chou12 Posted January 29, 2007 Share Posted January 29, 2007 Thanks :D Quote Link to comment https://forums.phpfreaks.com/topic/36182-php-date/#findComment-171851 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.