Work Week Calendar

I am looking for some assistance on best practice for the following scenario… Any and all help will be greatly appreciated.

I am looking to build a monthly calendar consisting of a five day week (work days). What I envision is a table five columns by four rows. Each cell in each row would have the date (ie. 02/27/2008).

I also need it to be a rolling calendar, the first row in the calendar when the script is called always needs to be the current week.
Any suggestions?

I think the date() and time() functions will come in handy for that.

Yeah, I have built the calendar using the date() and time() functions… But I am having a hard time omitting Sat and Sun successfully… Also, making it a rolling calendar has got me stumped as well…

if (substr(date("D", $nextday), 0, 1) == "S") { // Either Saturday or Sunday }

Should determine whether or not we’re talking about the weekend.

Don’t know what you mean with ‘rolling calendar’.

I really appreciate the reply… What I mean by a rolling calendar is I am list 4 work weeks on the page. The first week listed is always the current week, so no matter what date it is, it always has the current week as the first row. So the calendar could be including two different months depending on the current date. I hope I am explaining this clearly.

[code]
$prevday = date(“D”);
while (substr(date(“D”, $prevday), 0, 1) != “S”) {
$prevday -= 86400;
}

$nextday = $prevday + 86400;

echo “

”;
for ($numweeks = 1; $numweeks < 5; $numweeks++) {
echo “”;
while (substr(date(“D”, $nextday), 0, 1) != “S”) {
echo “";
$nextday += 86400;
}
echo “”;
$nextday += (2 * 86400);
}
echo “
”.$prevday."
”;[/code]

Something like this?

Looks like exactly what I am looking to do… When I ran it though…This is the output I got.

Warning: date() expects parameter 2 to be long, string given in C:newfile2.php on line 5
-259200 -259200 -259200 -259200 -259200
-259200 -259200 -259200 -259200 -259200
-259200 -259200 -259200 -259200 -259200
-259200 -259200 -259200 -259200 -259200

See my signature :)
I’m not trying to give you a solution to your problem, I’m trying to teach you something, and in order for you to learn, you’ll have to examine the code. If you don’t, you’ll never learn what the code is doing.

I’m thinking you just copy+pasted it and ran it. If it contained any malicious code, I could have wiped your harddrive or installed a virus/backdoor on your PC.

Ah… Thanks for the reply… I will analyze the example you gave me and see what I can learn. :D I’m used to ignoring signatures due to them usually being advertisements for something…

Again, I really appreciate your help.

No problem :)

Sponsor our Newsletter | Privacy Policy | Terms of Service