I hope this is what you want:
const today = new Date();
const yyyy = today.getFullYear();
let mm = today.getMonth() + 1; // Months start at 0!
let dd = today.getDate();
if (dd < 10) dd = '0' + dd;
if (mm < 10) mm = '0' + mm;
const formattedToday = dd + '/' + mm + '/' + yyyy;
document.getElementById('DATE').value = formattedToday;
How do I get the current date in JavaScript?
Answer from Aelios on Stack OverflowMDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN
Due to the differing lengths of ... a number of issues, and should be thoroughly researched before being attempted. ... // Using Date objects const start = Date.now(); // The event to time goes here: doSomethingForALongTime(); const end = Date.now(); const elapsed = end - start; ...
Videos
16:02
Format Your Own Dates With JavaScript - YouTube
10:51
How to Format Dates with Vanilla JavaScript - YouTube
05:02
How to Get Current Date & Time in JavaScript | Date Object Tutorial ...
11:59
The Easiest Way to Format Dates in JavaScript - YouTube
15:32
Learn the Date Object by Building a Date Formatter | FreeCodeCamp ...
01:00
How To Easily Format Dates In JavaScript - YouTube
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › now
Date.now() - JavaScript | MDN
const start = Date.now(); doSomeLongRunningProcess(); console.log(`Time elapsed: ${Date.now() - start} ms`);
W3Schools
w3schools.com › jsref › jsref_now.asp
JavaScript Date now() Method
The syntax is always Date.now().
Top answer 1 of 7
721
I hope this is what you want:
const today = new Date();
const yyyy = today.getFullYear();
let mm = today.getMonth() + 1; // Months start at 0!
let dd = today.getDate();
if (dd < 10) dd = '0' + dd;
if (mm < 10) mm = '0' + mm;
const formattedToday = dd + '/' + mm + '/' + yyyy;
document.getElementById('DATE').value = formattedToday;
How do I get the current date in JavaScript?
2 of 7
250
I honestly suggest that you use moment.js. Just download moment.min.js and then use this snippet to get your date in whatever format you want:
<script>
$(document).ready(function() {
// set an element
$("#date").val( moment().format('MMM D, YYYY') );
// set a variable
var today = moment().format('D MMM, YYYY');
});
</script>
Use following chart for date formats:

Moment.js
momentjs.com › docs
Moment.js | Docs
Get + Set Millisecond Second Minute Hour Date of Month Day of Week Day of Week (Locale Aware) ISO Day of Week Day of Year Week of Year Week of Year (ISO) Month Quarter Year Week Year Week Year (ISO) Weeks In Year Weeks In Year (ISO) Get Set Maximum Minimum · Manipulate Add Subtract Start of Time End of Time Maximum Minimum Local UTC UTC offset Time zone Offset · Display Format Time from now ...
Python documentation
docs.python.org › 3 › library › datetime.html
datetime — Basic date and time types
Same as datetime.strftime(). This makes it possible to specify a format string for a datetime object in formatted string literals and when using str.format(). See also strftime() and strptime() behavior and datetime.isoformat(). Examples of working with datetime objects: >>> import datetime as dt >>> # Using datetime.combine() >>> d = dt.date(2005, 7, 14) >>> t = dt.time(12, 30) >>> dt.datetime.combine(d, t) datetime.datetime(2005, 7, 14, 12, 30) >>> # Using datetime.now() >>> dt.datetime.now() datetime.datetime(2007, 12, 6, 16, 29, 43, 79043) # GMT +1 >>> dt.datetime.now(dt.timezone.utc) date
Microsoft Learn
learn.microsoft.com › en-us › dotnet › standard › base-types › standard-date-and-time-format-strings
Standard date and time format strings - .NET | Microsoft Learn
Learn how to use a standard date and time format string to define the text representation of a date and time value in .NET.
Adobe
helpx.adobe.com › coldfusion › cfml-reference › coldfusion-functions › functions-c-d › DateFormat.html
DateFormat
December 4, 2025 - <cfscript> // This snippet throws an exception writeOutput("The date is: " & DateFormat('04/10','mm-dd')) </cfscript> ... If you set the above flag as D, the snippet below produces the same output when the mask is set to d. <cfscript> writeOutput(dateformat(now(), "mm-D-yyyy") & "<br/>") ...
W3Schools
w3schools.com › js › js_date_formats.asp
JavaScript Date Formats
JS Examples JS HTML DOM JS HTML Input JS HTML Objects JS HTML Events JS Browser JS Editor JS Exercises JS Quiz JS Website JS Syllabus JS Study Plan JS Interview Prep JS Bootcamp JS Certificate JS Reference ... The ISO format follows a strict standard in JavaScript. The other formats are not so well defined and might be browser specific. Independent of input format, JavaScript will (by default) output dates in full text string format:
Top answer 1 of 16
1660
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]
2 of 16
998
You can do:
function formatDate(date) {
var d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2)
month = '0' + month;
if (day.length < 2)
day = '0' + day;
return [year, month, day].join('-');
}
console.log(formatDate('Sun May 11,2014'));
Usage example:
console.log(formatDate('Sun May 11,2014'));
Output:
2014-05-11
Demo on JSFiddle: http://jsfiddle.net/abdulrauf6182012/2Frm3/