Can figure out whats wrong

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have I strange problem /bug in my function and I hoping someone can tell
me whats wrong.

This function return the timestamp for midnight Monday on the given week
number.

Its working fine, but on week 44 and week 45 it misses with 3600 seconds (1
hour)

I wounder if it's a bug in strtotime() or it something I'm doing, it only
week 44 and 45.

 

I hope someone can give me an answer on this problem.

 

function week2Timestamp ($weekno)

{

            $first_day_of_year = date('w', mktime(0,0,0,1,1, date('Y')));

            if ($first_day_of_year == 0)

            {

                        $first_day_of_year = 7;

            }

                        

            $day = ($weekno -1) * 7 + 1 - $first_day_of_year;

            $timestamp = strtotime('next Monday', mktime(0, 0, 0, 1, $day,
date('Y')));

                        

            return $timestamp;

}

 

- Anders


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux