maxudaskin Posted June 28, 2008 Share Posted June 28, 2008 I know it is possible (in some way) to figure out the number of weeks in a month, but not in the way you are probably thinking. What I want to do is make a calendar for my website. I don't want to use a pre-made script because I want (I want a lot of things ) to make my whole site integrated and have it look good together. I want to be able to figure out how many weeks a month falls under if a week is: Sun, Mon, Tue, Wed, Thu, Fri, Sat If a month was to start on a Thursday and last 31 days, then it would have 5 weeks as illustrated below. Sun, Mon, Tue, Wed, Thu, Fri, Sat 1: 1 2 3 2: 5 6 7 8 9 10 11 3: 12 13 14 15 16 17 18 4: 19 20 21 22 23 24 25 5: 26 27 28 29 30 31 Quote Link to comment https://forums.phpfreaks.com/topic/112283-number-of-weeks/ Share on other sites More sharing options...
br0ken Posted June 28, 2008 Share Posted June 28, 2008 If you have the code already to produce the table you have in your post, could you not just have a counter variable that is initialised to 0 and increment each time you echo a new table row. This would then at the end hold the number of weeks in the given month. If for some reason you wanted this value before you echo the calender table you could simply store the table in a variable untill ready for echoing. Quote Link to comment https://forums.phpfreaks.com/topic/112283-number-of-weeks/#findComment-576466 Share on other sites More sharing options...
maxudaskin Posted June 28, 2008 Author Share Posted June 28, 2008 That wasn't code, it was just a visualization. But that just may be crazy enough to work. Quote Link to comment https://forums.phpfreaks.com/topic/112283-number-of-weeks/#findComment-576469 Share on other sites More sharing options...
.josh Posted June 28, 2008 Share Posted June 28, 2008 I know that I should be shot for saying this, but honestly I think it would be easier to just hardcode it into an array. I mean, 12 elements has you covered for the next year...just pick up a calendar and count. I mean, I really don't see a reason for making a code recalculate something like this every single page load... Quote Link to comment https://forums.phpfreaks.com/topic/112283-number-of-weeks/#findComment-576472 Share on other sites More sharing options...
maxudaskin Posted June 28, 2008 Author Share Posted June 28, 2008 Quote Link to comment https://forums.phpfreaks.com/topic/112283-number-of-weeks/#findComment-576484 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.