0

I'm using php date('W'); function to get a number of the week of this year.

date('W')  says "40" (that's correct).

The problem is, that my Linux machine, CentOS has a correct date, but shows incorrect week number.

date +"%W" says "39"

Does anyone know why it works this way and how could I fix it?

jomajo
  • 37
  • 3
  • 10

2 Answers2

0

Okay, I found the answer:

I need to use it like this: date +%V

%V ISO week number, with Monday as first day of week (01..53)

%W week number of year, with Monday as first day of week (00..53)

jomajo
  • 37
  • 3
  • 10
0
date('W');

The code above gives the ISO-8601 week number (don't know what Linux shows by default). If you want the correct year there as well, use

date('W o');

instead of (W Y), because the o gives the right year with the W-week.

Ivo Geersen
  • 195
  • 1
  • 8