1

I got the date as follow

const today = new Date();

now I need to get the week number of the year. How do I get it on the typescript?

I tried const todayFormated = this.datepipe.transform(today, 'W'); but it is returning the week number of the month not year

Pac0
  • 21,465
  • 8
  • 65
  • 74
nifCody
  • 2,394
  • 3
  • 34
  • 54
  • It is not JS. the this is TS – nifCody Jan 29 '19 at 14:21
  • actually, that's valid EcmaScript6 JS as well. Anyway, I'm tempted to remove the Typescript tag, as the question has not much to do with the TS language. – Pac0 Jan 29 '19 at 14:26

1 Answers1

3

It is lowercase 'w': const todayFormated = this.datepipe.transform(today, 'w');.

From the Angular Documentation:

Week of year w Numeric: minimum digits 1... 53

Week of month W Numeric: 1 digit 1... 5

Community
  • 1
  • 1
Fabian Küng
  • 5,925
  • 28
  • 40