RE: [PHP] Re: Issue with 'W' in the date() function?

2004-02-04 Thread Ford, Mike [LSS]
On 03 February 2004 16:16, William Bailey contributed these pearls of wisdom: Ok. Its been a long day and my brain is starting to shut down so... How would i work out which year the 'W' relates to? I have a unix timestamp value and want to end up with the correct 'YW' value. Look at

[PHP] Re: Issue with 'W' in the date() function?

2004-02-03 Thread Michael Nolan
William Bailey wrote: Hi all, Can somebody please explain this for me... [EMAIL PROTECTED]:/usr/home/wb [11]- php ?php $time = strtotime('now -5 weeks'); printf(\n\n%s is in week %d of the year %d\n\n, date('Y-m-d', $time), date('W', $time), date('Y', $time)); ? ^D 2003-12-30 is in week 1

Re: [PHP] Re: Issue with 'W' in the date() function?

2004-02-03 Thread William Bailey
Hi Mike, Because week 1 is defined as the first week with four or more days in the new year. Therefore, working backwards, the 29th-31st are also in week 1 in 2004. Thanks, So now i will just have to check the year and then work out from that what the correct year should be. (i need to get a

Re: [PHP] Re: Issue with 'W' in the date() function?

2004-02-03 Thread William Bailey
Ok. Its been a long day and my brain is starting to shut down so... How would i work out which year the 'W' relates to? I have a unix timestamp value and want to end up with the correct 'YW' value. William Bailey wrote: Hi Mike, Because week 1 is defined as the first week with four or more

Re: [PHP] Re: Issue with 'W' in the date() function?

2004-02-03 Thread Jason Wong
On Wednesday 04 February 2004 00:16, William Bailey wrote: Ok. Its been a long day and my brain is starting to shut down so... How would i work out which year the 'W' relates to? I have a unix timestamp value and want to end up with the correct 'YW' value. Would it have anything to do with

Re: [PHP] Re: Issue with 'W' in the date() function?

2004-02-03 Thread William Bailey
I really have to stop replying to myself :) Anyway i think that i have the solution... function timestamp2YearWeek ($time) { if (date('z', $time) 360 date('W', $time) == 1) { return sprintf('%d%02d', date('Y', $time)+1, date('W', $time)); }else{ return sprintf('%d%02d',