Reputation: 19425
I have the following code:
var currentYear = moment().isoWeekYear().toString();
var currentWeek = moment().isoWeek().toString();
var endYear = moment().add(24, 'weeks').isoWeekYear().toString();
var endWeek = moment().add(24, 'weeks').isoWeek().toString();
This gives me 201734 - 20186
but I need 201734 - 201806
(the last 06). See fiddle.
I can of course check if week is < 10 and add a 0 to the string. But is there a way to format this using moment.js?
I tried using var currentWeek = moment().isoWeek().format('ww').toString()
but that didn't work well.
Upvotes: 2
Views: 2612
Reputation: 183
Use this to get Week Number in two digit: moment(new Date()).format('WW')
.
Upvotes: 4