How to format javascript date to yyyy-mm-dd

By Saruque Ahamed Mollick

In this JavaScript tutorial, we gonna learn how to format JavaScript date to YYYY-MM-DD easily. This is a very easy tutorial as you don’t need to work hard to Convert a date to YYYY-MM-DD.

To convert a date to YYYYMMDD in JavaScript, we have a built-in method that we can use.


We will use this method.

Also read,

how to subtract days from a date in javascript

How to compare two dates in JavaScript

Format JavaScript Date to YYYY-MM-DD

We will learn this with an easy example.

      <title>Title Goes Here</title>
         var current_date;
         var new_format_result;
         current_date = new Date();
         new_format_result = current_date.toISOString();




current_date = new Date();

This is used to store system date time in current_date variable


Now, this will return the Date in ISO standard.

This is known as ISO-8601 having a format like this:


toISOString() method return a string which represents the date and time in ISO format.

Finally, I would like to say you feel free to comment in the below comment section. Happy coding.

Also read,

How to add minutes to date in the JavaScript date object

how to subtract days from a date in javascript

Leave a Reply

Your email address will not be published. Required fields are marked *