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.

Answer from Samuel Meddows on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript - MDN Web Docs - Mozilla
When called as a constructor, returns a new Date object. When called as a function, returns a string representation of the current date and time.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-get-current-date-todays-date-in-js
JavaScript Get Current Date – Today's Date in JS
November 7, 2024 - In JavaScript, we can easily get the current date or time by using the new Date() object. By default, it uses our browser's time zone and displays the date as a full text string, such as "Fri Jun 17 2022 10:54:59 GMT+0100 (British Summer Time)" ...
🌐
W3Schools
w3schools.com › jsref › jsref_tostring_date.asp
JavaScript Date toString() Method
cssText getPropertyPriority() ... d = new Date(); let text = d.toString(); Try it Yourself » · The toString() method returns a date object as a string....
🌐
W3Schools
w3schools.com › js › js_dates.asp
JavaScript Dates
February 4, 2026 - Date methods and time zones are covered in the next chapters. JavaScript will (by default) output dates using the toString() method. This is a string representation of the date, including the time zone.
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to use javascript to get the current date and time
How to Use JavaScript to Get the Current Date and Time
December 17, 2025 - By default, it uses your browser's time zone and displays the date as a full-text string, including the current day, date, time, and time zone. To adjust a date by timezone in JavaScript, use the Date object and the toLocaleString() method.
🌐
Bugfender
bugfender.com › blog › javascript-date-and-time
The Definitive Guide to JavaScript Date and Time | Bugfender
February 18, 2025 - To get the current date, you can use the new Date() constructor without passing any arguments. This returns the current date and time in a long date-time representation​​. To format a JavaScript date as “yyyy-mm-dd”, you can use the ...
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Date and time
The string format should be: YYYY-MM-DDTHH:mm:ss.sssZ, where: YYYY-MM-DD – is the date: year-month-day. The character "T" is used as the delimiter.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-get-the-current-date-in-javascript
How to Get the Current Date in JavaScript ? - GeeksforGeeks
July 11, 2025 - The Date() object is used to access the current date in JavaScript. To get the current date in string format, we can use toDateString() method. The date.toDateString() method converts the given date object into the date portion into a string.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › Date
Date() constructor - JavaScript - MDN - Mozilla
Any arguments given in a Date() ... or other primitive as an argument — it always returns a string representation of the current date and time. To offer protection against timing attacks and fingerprinting, the precision of new Date() might get rounded depending on browser ...
🌐
Scaler
scaler.com › home › topics › how to get the current date in javascript?
How to Get the Current Date in JavaScript - Scaler Topics
March 26, 2024 - The T serves as a literal to separate the date from the time, and the Z denotes zero hour offset also known as Zulu time (UTC). To get current date in javascript we will use the slice() string method.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toString
Date.prototype.toString() - JavaScript | MDN
July 10, 2025 - const event = new Date("August 19, 1975 23:15:30"); console.log(event.toString()); // Expected output: "Tue Aug 19 1975 23:15:30 GMT+0200 (CEST)" // Note: your timezone may vary ... A string representing the given date (see description for the format).
🌐
SheCodes
shecodes.io › athena › 6172-how-to-get-current-date-in-javascript
[JavaScript] - How to Get Current Date in JavaScript - | SheCodes
Use the JavaScript Date Object and the toDateString() Method to get the current date in JavaScript.
🌐
TutorialsTeacher
tutorialsteacher.com › javascript › javascript-date
JavaScript Date: Create, Convert, Compare Dates in JavaScript
Use the new keyword in JavaScript to get the Date object. ... Date(); //Returns current date and time string //or var currentDate = new Date(); //returns date object of current date and time
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toDateString
Date.prototype.toDateString() - JavaScript - MDN - Mozilla
const event = new Date(1993, 6, 28, 14, 39, 7); console.log(event.toString()); // Expected output: "Wed Jul 28 1993 14:39:07 GMT+0200 (CEST)" // Note: your timezone may vary console.log(event.toDateString()); // Expected output: "Wed Jul 28 1993" ... A string representing the date portion of ...
🌐
W3Schools
w3schools.com › js › js_date_methods.asp
JavaScript Get Date Methods
In JavaScript, date objects are created with new Date(). new Date() returns a date object with the current date and time. ... The get methods above return Local time. Universal time (UTC) is documented at the bottom of this page.
🌐
W3Resource
w3resource.com › javascript-exercises › javascript-basic-exercise-3.php
JavaScript: Display the current date in various format - w3resource
This JavaScript program retrieves the current date and formats it in multiple ways (mm-dd-yyyy, mm/dd/yyyy, dd-mm-yyyy, dd/mm/yyyy). It uses the Date object to get the current day, month, and year, and then adds leading zeros if necessary to ensure proper formatting. Finally, it logs the formatted date strings ...
🌐
freeCodeCamp
freecodecamp.org › news › javascript-date-now-how-to-get-the-current-date-in-javascript
JavaScript Date Now – How to Get the Current Date in JavaScript
June 15, 2020 - In this guide, you will learn how to get the current date in various formats in JavaScript. JavaScript has a built-in Date object that stores the date and time and provides methods for handling them. To create a new instance of the Date object, use the new keyword: ... The Date object contains a Number that represents milliseconds passed since the Epoch, that is 1 January 1970. You can pass a date string ...