I need a (automatically populate a form field) PHP function which will return a value of either 4 or 5 for a given month, which represents the number of Mondays in that month (calendar weeks). Cheers
Asked
Active
Viewed 2,846 times
4
-
8Interesting question, but what have you tried? – Polynomial Jan 28 '12 at 21:50
-
Very similar to http://stackoverflow.com/questions/5069966/in-php-how-to-know-how-many-mondays-have-passed-in-this-month-uptil-today – Michael Mrozek Jan 28 '12 at 21:51
-
Start by getting the day of the 1st – QuentinUK Jan 28 '12 at 21:51
-
"not a real question"? "cannot be reasonably answered in its current form"? Seriously? – sdleihssirhc Jan 28 '12 at 21:52
-
1This could help http://stackoverflow.com/questions/1321668/find-how-many-sunday-from-2-given-dates – Mike Jan 28 '12 at 21:54
-
Exactly the same http://stackoverflow.com/questions/1653891/how-to-find-number-of-mondays-or-tuesdays-between-two-dates – Cheery Jan 28 '12 at 21:56
-
Each month for a given year has a certain number of Mondays, e.g. this month has 5, whilst next month has 4...So if I pass today's date I will get a return value 5 (Janurary 2012 has 5 Mondays/Calendar weeks 1 to 5)... – Cronin O'M Jan 28 '12 at 21:57
-
4@sdleihssirhc "Write this code for me" is generally frowned upon. Or wildly upvoted. Sometimes both – Michael Mrozek Jan 28 '12 at 21:58
-
I don't expect the code to be written for me...A break-down of the logic involved would be helpful and appreciated... – Cronin O'M Jan 28 '12 at 22:02
-
A question that starts with "I need ..." is an immediate red flag. The three similar questions mentioned above should have all the info you need. – JJJ Jan 28 '12 at 22:05
-
Fair enough...I didn't mean to come across that way...Thanks mugur, that is exactly what I needed, very much appreciated... – Cronin O'M Jan 28 '12 at 22:08
-
This code does what I need: – Cronin O'M Jan 28 '12 at 22:23