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.
Discussions

html - How to get current formatted date dd/mm/yyyy in Javascript and append it to an input - Stack Overflow
I would like to add a current date to a hidden HTML tag so that it can be sent to the server: How can I add a More on stackoverflow.com
🌐 stackoverflow.com
javascript - Get String in YYYYMMDD format from JS date object? - Stack Overflow
I've been searching for days for ... in Javascript, and this does the trick! 2017-05-12T13:12:03.35Z+00:00 ... Another way is to use toLocaleDateString with a locale that has a big-endian date format standard, such as Sweden, Lithuania, Hungary, South Korea, ...: ... This does not have the potential error you can get with UTC date ... More on stackoverflow.com
🌐 stackoverflow.com
How to REALLY get a UTC Date object

var date = new Date('2015-10-11T14:03:19.243Z'); var str = date.toISOString();

More on reddit.com
🌐 r/javascript
6
1
February 2, 2014
Why is C++ so terrible when it comes to date/time manipulation?
snort ... Did somebody call? :-) More on reddit.com
🌐 r/cpp
153
260
January 14, 2021
🌐
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....
🌐
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 ...
🌐
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.
🌐
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.
Find elsewhere
🌐
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.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › Date
Date() constructor - JavaScript - MDN Web Docs - 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 ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toString
Date.prototype.toString() - JavaScript - MDN Web Docs - Mozilla
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).
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-get-the-current-date-in-javascript
How to Get the Current Date in JavaScript ? - GeeksforGeeks
July 11, 2025 - 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. Syntax · dateObj.toDateString() JavaScript · // Create a Date Object ...
🌐
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.
🌐
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.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toTimeString
Date.prototype.toTimeString() - JavaScript - MDN Web Docs
July 10, 2025 - The toTimeString() method of Date instances returns a string representing the time portion of this date interpreted in the local timezone.
🌐
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 ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toDateString
Date.prototype.toDateString() - JavaScript - MDN Web Docs
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 ...
🌐
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
🌐
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 - You need to replace the strings "mm", "dd", "yy" with the respective month, day and year values from the format string passed in the argument. To do that you can use the replace() method like shown below: ... But this will lead to a lot of method chaining and make it difficult to maintain as you try to make the function more flexible: format.replace('mm', date.getMonth() + 1) .replace('yy', date.getFullYear()) .replace('dd', date.getDate());