To get the number of the month using Moment.js
jsximport moment from 'moment'; let numberOfMonth = moment().month('October').format('M'); // Number between 1 and 12 let numberOfMonth = moment().month('October').format('MM'); // Number between 01 and 12
To get the full date:
jsximport moment from 'moment'; let fullDate = moment().year(2025).month('October').date(27).format('YYYYMMDD'); // 20251027
Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.