Jump to content

Recommended Posts

Hi all

I currently have a support form which allows people to select a contact date, this is done with 3 drop down selection boxes

Day
Month
Year

I 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 ace

Thanks in advance

Ed
Link to comment
https://forums.phpfreaks.com/topic/36182-php-date/
Share on other sites

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 days
if ((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
Link to comment
https://forums.phpfreaks.com/topic/36182-php-date/#findComment-171829
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.