Use new Date() to generate a new Date object containing the current date and time.
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();
today = mm + '/' + dd + '/' + yyyy;
document.write(today);
This will give you today's date in the format of mm/dd/yyyy.
Simply change today = mm +'/'+ dd +'/'+ yyyy; to whatever format you wish.
Videos
Use new Date() to generate a new Date object containing the current date and time.
var today = new Date();
var dd = String(today.getDate()).padStart(2, '0');
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
var yyyy = today.getFullYear();
today = mm + '/' + dd + '/' + yyyy;
document.write(today);
This will give you today's date in the format of mm/dd/yyyy.
Simply change today = mm +'/'+ dd +'/'+ yyyy; to whatever format you wish.
var utc = new Date().toJSON().slice(0,10).replace(/-/g,'/');
document.write(utc);
Use the replace option if you're going to reuse the utc variable, such as new Date(utc), as Firefox and Safari don't recognize a date with dashes.
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?
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:

const dateObj = new Date();
const month = dateObj.getUTCMonth() + 1; // months from 1-12
const day = dateObj.getUTCDate();
const year = dateObj.getUTCFullYear();
const newDate = year + "/" + month + "/" + day;
// Using template literals:
const newDate = `${year}/${month}/${day}`;
// Using padded values, so that 2023/1/7 becomes 2023/01/07
const pMonth = month.toString().padStart(2,"0");
const pDay = day.toString().padStart(2,"0");
const newPaddedDate = `${year}/${pMonth}/${pDay}`;
or you can set new date and give the above values
new Date().toISOString()
"2016-02-18T23:59:48.039Z"
new Date().toISOString().split('T')[0];
"2016-02-18"
new Date().toISOString().replace('-', '/').split('T')[0].replace('-', '/');
"2016/02/18"
new Date().toLocaleString().split(',')[0]
"2/18/2016"
Source: https://www.webdevmonk.com/tutorials/js-tutorial-in-45minutes.html#14
You can create a new Date object by calling the Date constructor with no arguments, which will create a Date object set to the current date and time:
let currentDate = new Date();
Once you have a Date object, you can use its methods to get and set the date and time.
let currentDate = new Date();
console.log(currentDate.getFullYear()); // returns the year (e.g. 2022)
console.log(currentDate.getMonth()); // returns the month (0-11)
console.log(currentDate.getDate()); // returns the day of the month (1-31)
console.log(currentDate.getHours()); // returns the hour (0-23)
console.log(currentDate.getMinutes()); // returns the minute (0-59)
console.log(currentDate.getSeconds()); // returns the second (0-59)
currentDate.setFullYear(2021); // sets the year to 2021
currentDate.setMonth(11); // sets the month to December (11)
currentDate.setDate(25); // sets the day of the month to 25
currentDate.setHours(12); // sets the hour to 12 (noon)
currentDate.setMinutes(0); // sets the minute to 0
currentDate.setSeconds(0); // sets the second to 0
You can also create a Date object for a specific date and time by passing arguments to the Date constructor.
let birthday = new Date(1995, 0, 1); // January 1st, 1995
let meeting = new Date(2022, 11, 16, 13, 30, 0); // December 16th, 2022, 1:30 PM