tkm Posted July 3, 2008 Share Posted July 3, 2008 Hello Mates, I am using the following function to get the month name from week number of a year. date( "M", strtotime( "+$wk_no week", mktime(0, 0, 0, 1, 1, 2008) ) ) But what happens when the week extends to 2 different months ? Can anyone help me with any insights or suggestions ? Thank you. Quote Link to comment Share on other sites More sharing options...
TransmogriBenno Posted July 3, 2008 Share Posted July 3, 2008 That code gives you the first day of that week. You then add another 6 days to get the last day of the week, and then get the month name again. If they are different, you know the week spans two months. Alternatively, you could see if the day of month + 6 is more than the number of days in the month. That way you can delay working out the month name a second time, in case you don't need to. But it's probably not a real performance issue, anyway. Quote Link to comment Share on other sites More sharing options...
grimmier Posted July 3, 2008 Share Posted July 3, 2008 Remember that January 1 is not always in the "first week" of the year. it can fall in the 52nd week. BUT January 4th is ALWAYS in the first week of the year. Quote Link to comment 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.