tags:

views:

45

answers:

3

Sorry for the title....In PHP I use the date('w',mydate) to get the week and then I got the week of the date.If user clik next week it increments the current week by one.

For example date('w',2009-12-10 05:00:00) it returns week as 50.if i click next week button iincrement as 51 and display the dates.at the end of 53 eeks also it takes as 54,55,56,etc... But I want to display as 1st week of january 2010.How can I do?

+2  A: 
strtotime('+1 week', $timestamp);
Galen
Is there any other way....
vinothkumar
why do you not like this way?
Galen
A: 

The other way is:

$week++;
if ( $week > 52 )
{
  $week = 1;
  $year++;
}
Salman A
Some years have 53 weeks. This is not taken into consideration here. See http://en.wikipedia.org/wiki/Seven-day_week#Week_numbering
berkes
A: 

It's not very clear from your question what you want to do, but ...

Because there are not exactly 52 weeks of 7 days in a year, and because the 'weeknumber' is incremented every Monday (at least in my desk diary) you'll find that the last few days of December are week 53.

My desk diary shows Jan 1 as Week 1, and Dec 28..31 as week 53 of 2009.

Is this the problem? Are you unhappy about the week 53?

If your code is returning weeks 54, 55, 56, something is wrong with it and you should show us the code.

pavium