sw45acp Posted January 19, 2010 Share Posted January 19, 2010 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; } } Quote Link to comment https://forums.phpfreaks.com/topic/189068-showing-only-monday-thursday-in-this-simple-calendar/ Share on other sites More sharing options...
greatstar00 Posted January 19, 2010 Share Posted January 19, 2010 //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; } } Quote Link to comment https://forums.phpfreaks.com/topic/189068-showing-only-monday-thursday-in-this-simple-calendar/#findComment-998253 Share on other sites More sharing options...
sw45acp Posted January 19, 2010 Author Share Posted January 19, 2010 excellent that works fine thank you. Quote Link to comment https://forums.phpfreaks.com/topic/189068-showing-only-monday-thursday-in-this-simple-calendar/#findComment-998256 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.