Jump to content

PHP Date


CanMan2004

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.