When I try to get the week number for Dec 31, it returns 1. When I get the week number for Dec 30, I get 52 --- which is what I would expect. The day Monday is correct. This is on a RPI running Ubuntu.

$ date -d "2018-12-30T1:58:55" +"%V%a"


$ date -d "2018-12-31T1:58:55" +"%V%a"


Same issue without time string

$ date -d "2018-12-31" +"%V%a"


2 Answers 2


This is giving you the ISO week which begins on a Monday.

The ISO week date system is effectively a leap week calendar system that is part of the ISO 8601 date and time standard issued by the International Organization for Standardization (ISO) since 1988 (last revised in 2004) and, before that, it was defined in ISO (R) 2015 since 1971. It is used (mainly) in government and business for fiscal years, as well as in timekeeping. This was previously known as "Industrial date coding". The system specifies a week year atop the Gregorian calendar by defining a notation for ordinal weeks of the year.

An ISO week-numbering year (also called ISO year informally) has 52 or 53 full weeks. That is 364 or 371 days instead of the usual 365 or 366 days. The extra week is sometimes referred to as a leap week, although ISO 8601 does not use this term.

Weeks start with Monday. Each week's year is the Gregorian year in which the Thursday falls. The first week of the year, hence, always contains 4 January. ISO week year numbering therefore slightly deviates from the Gregorian for some days close to 1 January.

If you want to show 12/31 as week 52, you should use %U, which does not use the ISO standard:

$ date -d "2018-12-31T1:58:55" +"%V%a"
$ date -d "2018-12-31T1:58:55" +"%U%a"
  • Thanks. That is what I was looking for. I used a much more convoluted method with the cal command. Nov 16, 2018 at 21:10

The definition of the week number is different between Europe and the USA, probably ISO versus ANSI standards. This may be related to a week being Sunday--Saturday or Monday--Sunday, and this again may be related to the Jewish versus Christian definition of the Lord's Day (Sabbath vs Sunday).

For Europe, week number 1 contains the first Thursday in January, and thus it contains a minimum of 4 days (i.e. a majority) belonging to the new year (Thu-Fri-Sat-Sun).

Anyway, in such years when ALL (!!) week numbers are +/- 1 different between Europe and the USA this gives great fun with setting schedules in multi-national companies. :-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .