By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,360 Online
Bytes IT Community
+ Ask a Question
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
Share this Question
Share on Google+
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" <pa**********@btinternet.comwrote in message
news:5u*************@mid.individual.net...
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')
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" <we************@seemy.sigwrote in message
news:XP******************************@comcast.com. ..
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|
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" <no****@example.comwrote in message
news:wK***************@newsfe05.lga...
>
"Paul Lautman" <pa**********@btinternet.comwrote in message
news:5u*************@mid.individual.net...
>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')

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" <root@localhostwrote in message
news:47***********************@news.euronet.nl...
>
"Steve" <no****@example.comwrote in message
news:wK***************@newsfe05.lga...
>>
"Paul Lautman" <pa**********@btinternet.comwrote in message
news:5u*************@mid.individual.net...
>>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')

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?
more than one way to skin a cat. :)
Jan 8 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.