Welcome to the Geeks & God Static Archive. Read more »

How to avoid weekends?

Joined: 11/28/2008

Hi Guys,

I seem to be running into a problem for recurring bookings. If they make a recurring say for more than 10 days, i want to know about it.

But i wasnt to give them an option of inlcuding weekends or not, coz that would make a difference in the days they actually want

Currently I have a javascript pop-up calendar, where they get to choose their start and end date?

Any ideas for options of including or excluding weekends



Joined: 11/28/2008
Hi Silpa I'm not quite clear

Hi Silpa

I'm not quite clear on what it is you are wanting to do. If you want to know if a particular booking includes a weekend, you could loop through the days of the booking and check if any of the days are a Saturday or Sunday like this:

<SCRIPT LANGUAGE="Javascript">


day1 = new Date(bookingyear1,bookingmonth1,bookingday1,0,0,0);

day2 = new Date(bookingyear2,bookingmonth2,bookingday2,0,0,0);

// OR day2 = new Date(day1.getTime() + (numdays*24*60*60));

for (i = day1.getTime(); i <= day2.getTime(); i+=24*60*60) {

 testday = newDate(i);

 if ((testday.getDay() == 0) || (testday.getDay()==6)) {

   // this day is a weekend day - 0 is Sunday, 6 is Saturday

   if (canbookweekend == True) {

     // add this day to booking


   else {

     // skip to next day



 else { // not a weekend day

   // add day to booking





Paul Davey
Whitford Church
"Everyone who calls on the name of the Lord will be saved." Romans 10:13
"For all have sinned and fall short of the glory of God, and are justified

Joined: 11/28/2008
Hi Silpa, You might find this

Hi Silpa,

You might find this script useful:


Joined: 11/28/2008
Thank you guys for the

Thank you guys for the help.

I tiried the code, and worked around it into php and it did it for me:)