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
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN
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). Defaults to 01.
Discussions

Convert date in JavaScript to yyyy-mm-dd format
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, ... More on community.latenode.com
🌐 community.latenode.com
0
December 3, 2024
How get a date formatted like 2023-02-07 in JS?
You can do a quick and dirty format to yyyy-mm-dd with date.toISOString().slice(0, 10) More on reddit.com
🌐 r/webdev
26
0
March 13, 2023
html - How to get current formatted date dd/mm/yyyy in Javascript and append it to an input - Stack Overflow
I would like to add a current date to a hidden HTML tag so that it can be sent to the server: How can I add a More on stackoverflow.com
🌐 stackoverflow.com
javascript - How do I get a date in YYYY-MM-DD format? - Stack Overflow
How could I get the Date() method to return a value in a "MM-DD-YYYY" format so it would return something like: ... I recommend using momentjs.com for all of your javascript date needs, it makes everything much easier. More on stackoverflow.com
🌐 stackoverflow.com
🌐
W3Schools
w3schools.com › js › js_date_formats.asp
JavaScript Date Formats
Independent of input format, JavaScript will (by default) output dates in full text string format: ISO 8601 is the international standard for the representation of dates and times. The ISO 8601 syntax (YYYY-MM-DD) is also the preferred JavaScript date format:
🌐
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 - We use JavaScript built-in help methods from the Date class that help us to create a formatted version of the current date in the form of yyyy-mm-dd.
🌐
Latenode
community.latenode.com › other questions › javascript
Convert date in JavaScript to yyyy-mm-dd format - JavaScript - Latenode Official Community
December 3, 2024 - 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, ...
🌐
Reddit
reddit.com › r/webdev › how get a date formatted like 2023-02-07 in js?
r/webdev on Reddit: How get a date formatted like 2023-02-07 in JS?
March 13, 2023 -

I'm going insane. I had this feature working perfectly. Took 2 weeks vacation. I come back and it's broken.

I know y'all will say this is impossible, but I was getting that format by using `date.toLocaleDateString('en-CA')`. I know the spec says that format is "dd/MM/yyyy", which isn't what I want, but I was giving me the format in the title, I swear to God.

This is such a stupid little thing but I've already spent hours on SO. It's just endless threads about people confused about datetimes and the differences between timezones and offsets and no one's talking about this silly little thing.

I have my new date: Wed Feb 08 2023 00:00:00 GMT-0500 (Eastern Standard Time)

I just need a simple operation to flip the string around so it becomes 2023-03-08

That is it. Please help

p.s. the date is always set to midnight user local time so offset can be ignored. Whatever day they're experiencing is the day to be formatted. Thank you

🌐
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 - Format dates as YYYY-MM-DD using toISOString().split(“T”)[0] - the most reliable method for ISO date format in JavaScript.
Find elsewhere
🌐
GitHub
gist.github.com › Ivlyth › c4921735812dd2c0217a
format javascript date to format "YYYY-mm-dd HH:MM:SS" · GitHub
const ISO = (timeStamp=Date.now()) => { return new Date(timeStamp - (new Date().getTimezoneOffset() * 60 * 1000)).toISOString().slice(0,-5).split('T') } console.log('one->',ISO(new Date('2020-09-26 11:28:55').getTime())) console.log('now->',ISO()) one-> [ '2020-09-26', '11:28:55' ] now-> [ '2021-09-26', '20:13:36' ] js 时间格式化 date format YYYY-mm-dd HH:MM:SS
🌐
Medium
trymysolution.medium.com › javascript-date-as-in-yyyy-mm-dd-hh-mm-ss-format-or-mm-dd-yyyy-hh-mm-ss-a0c96e8fa888
JavaScript Date as in YYYY-MM-DD hh:mm:ss Format or MM/DD/YYYY hh:mm:ss | by Yogesh D V | Medium
April 11, 2023 - function padTwoDigits(num: number) ... padTwoDigits(date.getSeconds()), ].join(":") ); } :::: Exmple Usage :::: The function dateInYyyyMmDdHhMmSs takes a Date object as a parameter, divider ‘ — ’ or ‘ / ’ and formats ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › parse
Date.parse() - JavaScript | MDN
// Standard date-time string format const unixTimeZero = Date.parse("1970-01-01T00:00:00Z"); // Non-standard format resembling toUTCString() const javaScriptRelease = Date.parse("04 Dec 1995 00:12:00 GMT"); console.log(unixTimeZero); // Expected output: 0 console.log(javaScriptRelease); // Expected output: 818035920000
🌐
PTC Community
community.ptc.com › t5 › ThingWorx-Developers › Get-Date-yyyy-MM-dd-in-DateTime-format › td-p › 722959
Solved: Get Date (yyyy-MM-dd) in DateTime format - PTC Community
April 13, 2021 - Hi , I am looking to display date ... be DateTime. var d=new Date(); // dateFormat(dateValue:DATETIME, dateFormat:STRING):STRING var formattedDate = dateFormat(d, "yyyy-MM-dd"); // parseDate(stringDate:STRING, dateFormat:STRING):DATETIME var dateValue = ......
🌐
GitHub
gist.github.com › mohokh67 › e0c5035816f5a88d6133b085361ad15b
Get YYYY-MM-DD HH-MM-SS in JavaScript · GitHub
Get YYYY-MM-DD HH-MM-SS in JavaScript · Raw · timestamp-formatter.md · const formatedTimestamp = ()=> { const d = new Date() const date = d.toISOString().split('T')[0]; const time = d.toTimeString().split(' ')[0].replace(/:/g, '-'); return `${date} ${time}` } Sign up for free to join this conversation on GitHub.
🌐
Medium
medium.com › @Saf_Bes › get-current-date-in-format-yyyy-mm-dd-with-javascript-9c898d1d5b22
Get current date in format yyyy-mm-dd with Javascript | by Saf Bes | Medium
April 10, 2020 - Get current date in format yyyy-mm-dd with Javascript · To get the current date in javascript, I use Intl.DateTimeFormat · new Intl.DateTimeFormat("fr-CA", {year: "numeric", month: "2-digit", day: "2-digit"}).format(Date.now()) the expected output : 2019-11-20 ·
🌐
Bugfender
bugfender.com › blog › javascript-date-and-time
The Definitive Guide to JavaScript Date and Time | Bugfender
February 18, 2025 - This returns the current date and ... as “yyyy-mm-dd”, you can use the Date object and extract the year, month, and day components, then concatenate them into a string with the desired format....
🌐
freeCodeCamp
freecodecamp.org › news › javascript-date-now-how-to-get-the-current-date-in-javascript
JavaScript Date Now – How to Get the Current Date in JavaScript
June 15, 2020 - const formatMap = { mm: date.getMonth() + 1, dd: date.getDate(), yy: date.getFullYear().toString().slice(-2), yyyy: date.getFullYear() };
🌐
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 - Specific Date Format: To display a date in a specific format, such as DD/MM/YYYY, you can use Intl.DateTimeFormat with the appropriate options.
🌐
Tutorial Republic
tutorialrepublic.com › faq › how-to-format-javascript-date-as-yyyy-mm-dd.php
How to Format JavaScript Date as YYYY-MM-DD
You can simply use the toLocaleString() method to format a JavaScript date as yyyy-mm-dd. Let's take a look at the following example to understand how it basically works: ... // Create a date object from a date string var date = new Date("Wed, ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-get-current-formatted-date-dd-mm-yyyy-in-javascript
How to Get Current Formatted Date dd/mm/yyyy in JavaScript? - GeeksforGeeks
July 11, 2025 - '0' + month : month; // Format the date as dd/mm/yyyy const formattedDate = `${day}/${month}/${year}`; console.log(formattedDate); ... The Intl.DateTimeFormat() constructor is a built-in JavaScript object that enables language-sensitive date ...