424,988 Members | 1,360 Online
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

# Script to figure out if it's a weekend

 P: n/a Hey does anyone know of an easy script to use to figure out whether the current date is a weekend or not, i currently have a script that returns the current date and time. Also it would be great if it could take into account holidays. Jan 7 '08 #1
6 Replies

 P: n/a ys******@gmail.com wrote: Hey does anyone know of an easy script to use to figure out whether the current date is a weekend or not, i currently have a script that returns the current date and time. Also it would be great if it could take into account holidays. if (substr(date('D'),0,1) == 'S') Jan 7 '08 #2

 P: n/a ys******@gmail.com wrote: Hey does anyone know of an easy script to use to figure out whether the current date is a weekend or not, i currently have a script that returns the current date and time. Also it would be great if it could take into account holidays. |gregoriantojd(\$month, \$day, \$year) % 7 = \$day_of_the_week // Monday = 0| -- ***************************** Chuck Anderson • Boulder, CO http://www.CycleTourist.com Nothing he's got he really needs Twenty first century schizoid man. *********************************** Jan 7 '08 #3

 P: n/a "Paul Lautman" Hey does anyone know of an easy script to use to figure out whetherthe current date is a weekend or not, i currently have a script thatreturns the current date and time. Also it would be great if it couldtake into account holidays. if (substr(date('D'),0,1) == 'S') L.U.D.I.C.R.O.U.S !!! \$dateInfo = getdate(date()); \$isWeekend = in_array(\$dateInfo['wday], array(0, 6)); using substr is rediculous. 'domingo' is sunday and is ONE reason your suggestion blows. Jan 7 '08 #4

 P: n/a "Chuck Anderson" Hey does anyone know of an easy script to use to figure out whetherthe current date is a weekend or not, i currently have a script thatreturns the current date and time. Also it would be great if it couldtake into account holidays. |gregoriantojd(\$month, \$day, \$year) % 7 = \$day_of_the_week // Monday = 0| forgot about modulus! \$dateInfo = getdate(date()); \$isWeekend = \$dateInfo['wday'] % 6 == 0; that is faster than in_array. good catch. Jan 7 '08 #5

 P: n/a "Steve" "Paul Lautman" ys******@gmail.com wrote: >>Hey does anyone know of an easy script to use to figure outwhetherthe current date is a weekend or not, i currently have a scriptthatreturns the current date and time. Also it would be great if itcouldtake into account holidays. if (substr(date('D'),0,1) == 'S') L.U.D.I.C.R.O.U.S !!! \$dateInfo = getdate(date()); \$isWeekend = in_array(\$dateInfo['wday], array(0, 6)); using substr is rediculous. 'domingo' is sunday and is ONE reason your suggestion blows. if( date('N') == 6 || date('N') == 7) Wouldnt that do it? R. Jan 8 '08 #6

 P: n/a "Richard" "Steve" >"Paul Lautman" >ys******@gmail.com wrote:Hey does anyone know of an easy script to use to figure out whetherthe current date is a weekend or not, i currently have a script thatreturns the current date and time. Also it would be great if it couldtake into account holidays.if (substr(date('D'),0,1) == 'S') L.U.D.I.C.R.O.U.S !!!\$dateInfo = getdate(date());\$isWeekend = in_array(\$dateInfo['wday], array(0, 6));using substr is rediculous. 'domingo' is sunday and is ONE reason yoursuggestion blows. if( date('N') == 6 || date('N') == 7) Wouldnt that do it? more than one way to skin a cat. :) Jan 8 '08 #7

### This discussion thread is closed

Replies have been disabled for this discussion.