Javascript Date Formats

This date object can be used to get a year, month and day. We can display a timer on the webpage with the help of a JavaScript date object.

The formats of JavaScript’s date are defined as follows:


ISO Date

This date format is the international standard for the times and dates, and the syntax (YYYY-MM-DD) of this standard is the preferred date format in JavaScript.

Input:-
 <script>  
    let val = new Date("2020-08-01");  
    document.writeln(val);
</script>

Output:-


Short Date

This method use “MM/DD/YYYY”  format to write short dates.

Input:-
 <script>  
    let val = new Date("08/01/2020");  
    document.writeln(val);
</script>

Output:-


Long Date

This method use “MMM DD YYYY” format to write Long dates. The month and date can be written in any order, and it is allowed to write a month in abbreviated (Aug) form or in full (August).

Input:-
 <script>  
    let val = new Date("Aug 01 2020");   
    document.writeln(val);
</script>

Output:-