Search code examples
angularangular-date-format

angular 2 date pipe weeknumber


I looked up how to return the week number in Angular 2. I have not found an answer to this question. I did find on https://docs.angularjs.org/api/ng/filter/date that in Angular 1 it would be something like this: {{today | date:'w'}} but this does not seem to work in Angular 2. I know I can write a function to take care of this but this doesn't seem practical. Am I missing something in the documentation about Angular 2 or is this not (yet) implemented there?


Solution

  • The DatePipe currently doesn't support weekOfYear.

    You can implement your own WeekOfYear pipe though.
    See https://angular.io/docs/ts/latest/guide/pipes.html for more details.