Format a Date as YYYY-MM-DD using JavaScript | bobbyhadz
https://bobbyhadz.com/blog/javascript-format-date-yyyymmdd
WebMar 6, 2024 · To format a date as YYYY-MM-DD: Use the getFullYear(), getMonth() and getDate() methods to get the year, month and day of the date. Add a leading zero to the day and month digits if the value is less than 10. Add the results to an array and join them with a hyphen separator. index.js.
DA: 95 PA: 38 MOZ Rank: 7