nifCody
nifCody

Reputation: 2444

week number of the year by a given date

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

Upvotes: 1

Views: 5793

Answers (1)

Fabian Küng
Fabian Küng

Reputation: 6183

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

Upvotes: 3

Related Questions