Page 1 of 1

Week numbers

Posted: Thu Nov 18, 2004 9:01 am
by JayBird
If i have a week number, say 47

How can i convert that to a unix timestamp for the begining of that week?

P.S. The year and month would also be availble to the script.

So i need to work out the timestamp, use the following as an example

week = 47
month = 11
year = 2004

Posted: Thu Nov 18, 2004 9:06 am
by kettle_drum
Do a mktime() on the year, and then add (47*60*60*24*7).

Posted: Thu Nov 18, 2004 9:07 am
by JayBird
Would that be 100% correct?

Posted: Thu Nov 18, 2004 9:15 am
by kettle_drum
Umm probably not actually :S

You need to first see when the first monday of the year was - as that is when the first week should start counting from and then add that number of days onto the equation. I think that would then work 100% correct.

Posted: Thu Nov 18, 2004 9:19 am
by JayBird
how about working out the timestamp for the 1st monday of the year the using

strtotime("+47 weeks");

hmmmm....