Welcome to the discussion for the Featured content page! To leave a comment, log in and select Edit.

Improve Javascript fetch code for dates (month and day) without 2 digits, like 6th of march

If the current month and/or day has only 1 digit, then the code from the javascript example will not work. One solution is to change the month and day variables to:

let month = String(today.getMonth() + 1).padStart(2,'0');
let day = String(today.getDate().padStart(2,'0'));

to the date. D.legizynski (talk) 11:33, 7 March 2023 (UTC)[reply]

Great catch. Thanks, @D.legizynski! I've updated the code samples on this page and On this day. If you're interested in contributing to these docs, I'd be happy to add you to the documentation editors group, just let me know by leaving a comment on Talk:Community/Contributing. -APaskulin (WMF) (talk) 21:10, 7 March 2023 (UTC)[reply]