473,385 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Script to figure out if it's a weekend

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 1646
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
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

"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

"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

"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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: AdityaK | last post by:
Is there a way to find Weekend date for a given date using a DB2 query? I see that there are scalar functions such as DAY, DAYOFMONTH, DAYOFWEEK,etc are available...but couldn't find one to get a...
24
by: Dave | last post by:
Maybe I'm missing something here, but I can't see the purpose of the 'finally' keyword. What is the difference between: try { doSomething() } catch { handleError(); }
3
by: jonathan.beckett | last post by:
Hi all, I released a new version of the "PluggedOut Blog" script at the weekend - it's a PHP/MySQL solution for blogs, journals, diaries or any kind of calendar application. Homepage......
4
by: robinsand | last post by:
Header File: car.h #if !defined CAR_H #define CAR_H enum TCarType { ctEconomy = 1, ctCompact, ctStandard, ctFullSize, ctMiniVan, ctSUV }; class Car { public: Car();
2
by: Joey Martin | last post by:
I have a sql database and ASP pages. How do I find out the DATES of THIS WEEKEND (fri-sun). If today is Tuesday, I want to show information posted for THIS WEEKEND. My table has a field...
3
by: darnnnel | last post by:
Hey guys, i have this code: SELECT * FROM QueryCases WHERE Weekday(QueryCases.StartDate) In ('1','7') AND QueryCases.Completed = False ORDER BY QueryCases.StartDate; the WHERE...
3
by: sigkill9 | last post by:
I've been working on this script all weekend and am almost done with it accept for one last detail; implementing a "process another number?" prompt after a user input is processed. The script...
30
by: Paul W Smith | last post by:
I have written a hit counter, which I believe counts the times my page is hit by a user for each unique session by the user. The relevant part of my code is below: If...
7
by: Mike | last post by:
I have a routine that's calculating business days but its not counting the weekend days that are between the start date and end date. If my start date is 9/26/08 and my end date is 10/01/08, I...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.