Just leverage the built-in toISOString method that brings your date to the ISO 8601 format:

let yourDate = new Date()
yourDate.toISOString().split('T')[0]

Where yourDate is your date object.

Edit: @exbuddha wrote this to handle time zone in the comments:

const offset = yourDate.getTimezoneOffset()
yourDate = new Date(yourDate.getTime() - (offset*60*1000))
return yourDate.toISOString().split('T')[0]
Answer from Darth Egregious on Stack Overflow
🌐
W3Schools
w3schools.com › js › js_date_formats.asp
JavaScript Date Formats
The ISO 8601 syntax (YYYY-MM-DD) is also the preferred JavaScript date format: const d = new Date("2015-03-25"); Try it Yourself »

Just leverage the built-in toISOString method that brings your date to the ISO 8601 format:

let yourDate = new Date()
yourDate.toISOString().split('T')[0]

Where yourDate is your date object.

Edit: @exbuddha wrote this to handle time zone in the comments:

const offset = yourDate.getTimezoneOffset()
yourDate = new Date(yourDate.getTime() - (offset*60*1000))
return yourDate.toISOString().split('T')[0]
Answer from Darth Egregious on Stack Overflow
🌐
CoreUI
coreui.io › answers › how-to-format-date-as-yyyy-mm-dd-in-javascript
How to format date as YYYY-MM-DD in JavaScript · CoreUI
September 30, 2025 - Use toISOString().split('T')[0] to format any date as YYYY-MM-DD. const formatted = new Date().toISOString().split('T')[0]
🌐
Wikipedia
en.wikipedia.org › wiki › List_of_date_formats_by_country
List of date formats by country - Wikipedia
2 days ago - The ISO 8601 format YYYY-MM-DD (2026-03-10) is intended to harmonise these formats and ensure accuracy in all situations.
🌐
IBM
ibm.com › docs › SS6V3G_5.3.1 › com.ibm.help.gswapplintug.doc › GSW_Date_Time_Formats.html
Date/Time Formats
The Date Formats global option changes the default date format for all maps or forms. However, the format of the existing date fields do not change; the default is only used for new maps or forms.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN
The format is as follows: ... YYYY is the year, with four digits (0000 to 9999), or as an expanded year of + or - followed by six digits. The sign is required for expanded years. -000000 is explicitly disallowed as a valid year. MM is the month, with two digits (01 to 12).
🌐
Day.js
day.js.org › docs › en › display › format
Format · Day.js
dayjs().format() // current date in ISO8601, without fraction seconds e.g. '2020-04-02T08:02:17-05:00' dayjs('2019-01-25').format('[YYYYescape] YYYY-MM-DDTHH:mm:ssZ[Z]') // 'YYYYescape 2019-01-25T00:00:00-02:00Z' dayjs('2019-01-25').format('DD/MM/YYYY') // '25/01/2019'
🌐
Latenode
community.latenode.com › other questions › javascript
Convert date in JavaScript to yyyy-mm-dd format - JavaScript - Latenode Official Community
December 3, 2024 - I possess a date string in the form Sun May 11, 2014. What is the best way to transform it into the format 2014-05-11 using JavaScript? function formatDate(inputDate) { const dateObj = new Date(inputDate); const year = dateObj.getFullYear(); const month = String(dateObj.getMonth() + 1).padStart(2, '0'); const day = String(dateObj.getDate()).padStart(2, '0'); return `${year}-${month}-${day}`; } const date = 'Sun May 11, 2014'; console.log(formatDate(date)); The code snippet...
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-format-javascript-date-as-yyyy-mm-dd
How To Format JavaScript Date as yyyy-mm-dd? - GeeksforGeeks
June 24, 2025 - Example: In this example, we will use the iso string method to format the JavaScript date as yyyy-mm-dd ... const formatDateISO = (date) => { return date.toLocaleDateString('en-CA'); }; const currentDate = new Date(); console.log(formatDate...
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-format-date-dd-mm-yyyy
How to Format a Date as DD/MM/YYYY in JavaScript | bobbyhadz
Copied!const date = new Date(); // ✅ DD/MM/YYYY const result1 = new Date().toLocaleDateString('en-GB'); console.log(result1); // 👉️ 24/07/2023 ... The code can also be tweaked to include the time. ... Copied!const date = new Date(); const result2 = new Date().toLocaleString('en-GB', { hour12: false, }); console.log(result2); // 👉️ 24/07/2023, 11:47:44 · We used the en-GB locale in a hacky way to format the date as DD/MM/YYYY.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-format-a-date-with-javascript-date-formatting-in-js
How to Format a Date with JavaScript – Date Formatting in JS
November 7, 2024 - const date = new Date(); const formattedDate = `${date.getDate()}-${date.getMonth() + 1}-${date.getFullYear()}`; console.log(formattedDate);
🌐
W3Resource
w3resource.com › javascript-exercises › javascript-basic-exercise-3.php
JavaScript: Display the current date in various format - w3resource
let today = new Date(); let dd = today.getDate(); let mm = today.getMonth()+1; const yyyy = today.getFullYear(); if(dd<10) { dd=`0${dd}`; } if(mm<10) { mm=`0${mm}`; } today = `${mm}-${dd}-${yyyy}`; console.log(today); today = `${mm}/${dd}/${yyyy}`; ...
🌐
Oracle
docs.oracle.com › cd › E41183_01 › DR › Date_Format_Types.html
Date Format Types
Month abbreviations consist of the first three characters of the month’s name. Months with four-character names, such as June, are not abbreviated · Month-Day-Year with leading zeros (02/17/2009)
🌐
LogRocket
blog.logrocket.com › home › how to format dates in javascript: methods, libraries, and best practices
How to format dates in JavaScript: Methods, libraries, and best practices - LogRocket Blog
May 8, 2025 - function formatDate(date, format) { const day = String(date.getDate()).padStart(2, '0'); const month = String(date.getMonth() + 1).padStart(2, '0'); const year = date.getFullYear(); const hours = String(date.getHours()).padStart(2, '0'); const minutes = String(date.getMinutes()).padStart(2, '0'); const seconds = String(date.getSeconds()).padStart(2, '0'); // Replace tokens with actual values return format .replace('YYYY', year) .replace('MM', month) .replace('DD', day) .replace('HH', hours) .replace('mm', minutes) .replace('ss', seconds); } const date = new Date('2025-02-18T14:30:45Z'); console.log(formatDate(date, 'YYYY-MM-DD')); // "2025-02-18" console.log(formatDate(date, 'DD/MM/YYYY HH:mm:ss')); // "18/02/2025 14:30:45" While this approach works, it quickly gets complex when you consider: Localization (month names, day names) Different calendar systems ·
🌐
Google Support
support.google.com › docs › thread › 287849418 › i-need-to-change-all-date-format-in-current-sheet-and-on-new-sheet-to-dd-mm-yyyy
I need to change all date format in current sheet and on new sheet to dd/mm/yyyy - Google Docs Editors Community
Skip to main content · Google Docs Editors Help · Sign in · Google Help · Help Center · Community · Google Docs Editors · Terms of Service · Submit feedback · Send feedback on
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › standard › base-types › custom-date-and-time-format-strings
Custom date and time format strings - .NET | Microsoft Learn
The "dd" custom format string represents the day of the month as a number from 01 to 31. A single-digit day is formatted with a leading zero. The following example includes the "dd" custom format specifier in a custom format string.