How To Format JavaScript Date as yyyy-mm-dd? Last Updated : 24 Jun, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. These are the approaches used to format JavaScript date as yyyy-mm-dd.Table of ContentUsing the ISO String Method USing JavaScript Method1. Using the ISO String Method The original method using the ISO string does not account for time zone differences. Here's how you can use toLocaleDateString() instead, which provides a more accurate result, taking into account the local time zone.Example: In this example, we will use the iso string method to format the JavaScript date as yyyy-mm-dd JavaScript const formatDateISO = (date) => { return date.toLocaleDateString('en-CA'); }; const currentDate = new Date(); console.log(formatDateISO(currentDate)); Output2024-09-252. Using JavaScript MethodIn this method, we will use the methods of JS to calculate year, month, and date. Further for date and month, for a single digit number, we will use padstart, which would add 0 to the start of the number if it is a number with less than 2 digits. Use a variable to combine all of these variables and print the formatted date. Example: In this example, we will use the javascript method to format the JavaScript date as yyyy-mm-dd JavaScript const formatDate = (date) => { const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, '0'); // Months are 0-indexed const day = String(date.getDate()).padStart(2, '0'); return `${year}-${month}-${day}`; }; // Example usage const currentDate = new Date(); console.log(formatDate(currentDate)); Output2024-09-25 Comment More infoAdvertise with us Next Article How to extract date from a string in dd-mmm-yyyy format in JavaScript ? R riyarjha Follow Improve Article Tags : JavaScript Web Technologies Similar Reads How to Get Current Formatted Date dd/mm/yyyy in JavaScript? Here are different ways to get the current date in dd/mm/yyyy format.1. Using Native JavaScript MethodsJavaScript's built-in Date object provides various methods to work with dates and times. You can extract individual components like day, month, and year to format the date manually.JavaScript// Get 2 min read How to Get Current Formatted Date dd/mm/yyyy in JavaScript? Here are different ways to get the current date in dd/mm/yyyy format.1. Using Native JavaScript MethodsJavaScript's built-in Date object provides various methods to work with dates and times. You can extract individual components like day, month, and year to format the date manually.JavaScript// Get 2 min read How to Format a Date in JavaScript? Here are different ways to format the date in JavaScript.1. Using the toDateString() MethodThe toDateString() method formats the date object into a human-readable format as Day Month Date Year.SyntaxdateObj.toDateString();JavaScriptconst date = new Date(); const formatDate = date.toDateString(); con 2 min read How to extract date from a string in dd-mmm-yyyy format in JavaScript ? In this article, we will see how to extract date from a given string of format "dd-mmm-yyyy" in JavaScript. We have a string, and we want to extract the date format "dd-mmm-yyyy" from the string.Example:// Stringstr = "India got freedom on 15-Aug-1947"// Extracted date from given string in // "dd-mm 2 min read How to format current date in MM/DD/YYYY HH:MM:SS format using JavaScript ? Given a date and the task is to format the current date in MM/DD/YYYY HH:MM:SS format. Here are a few of the most techniques discussed with the help of JavaScript. Approach 1: Store the current date in variable.Use the string concatenation technique to insert / and : in between the month-day and day 2 min read How to format current date in MM/DD/YYYY HH:MM:SS format using JavaScript ? Given a date and the task is to format the current date in MM/DD/YYYY HH:MM:SS format. Here are a few of the most techniques discussed with the help of JavaScript. Approach 1: Store the current date in variable.Use the string concatenation technique to insert / and : in between the month-day and day 2 min read Like