Jump to content

Recommended Posts

I wrote this very simple calendar to write out the dates of a given month and year.  It adds a line break at the end of each week. What I want, however, is for it to only output days that are Monday-Thursday, not Sunday,Friday, or Saturday. I would appreciate help on this matter.

 

//january 2010
$m = 1;
$y = 2010;
//calculate the number of days in the month
$days = date('t',mktime(0,0,0,$m, 1, $y));
//Calculate the day of the week that the month starts on
$startDay = date('w',mktime(0,0,0,$m, 1, $y));
for ($i=1; $i<=$days; $i++) {
//output the days with a space
echo $i . ' ';
//increment the startday
$startDay ++;
//if the start day equals seven, which is not possible because
//sunday = 0, saturday =6, so we need to start a new line
if ($startDay == 7) {
	echo '<br />';
	//set start day back to zero
	$startDay = 0;
}
}

//january 2010
$m = 1;
$y = 2010;
//calculate the number of days in the month
$days = date('t',mktime(0,0,0,$m, 1, $y));
//Calculate the day of the week that the month starts on
$startDay = date('w',mktime(0,0,0,$m, 1, $y));
for ($i=1; $i<=$days; $i++) {
//output the days with a space
                if($startday+1<5 && $startday>0)
          echo $i . ' ';
                else
                          echo '  ';//if not in mon to thurs, echo 2 spaces
//increment the startday
$startDay ++;
//if the start day equals seven, which is not possible because
//sunday = 0, saturday =6, so we need to start a new line
if ($startDay == 7) {
	echo '<br />';
	//set start day back to zero
	$startDay = 0;
}
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.