Re: [PHP] Can figure out whats wrong

2005-11-03 Thread Jochem Maas

freudian slip in the subject me thinks.

Anders Gjermshus wrote:

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)


something about the clocks going back?



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



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Can figure out whats wrong

2005-11-03 Thread Anders Gjermshus
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