How to Get the Current Date in JavaScript
A JavaScript Date is fundamentally specified as the number of milliseconds that have elapsed since midnight on January 1, 1970, UTC. By default, JavaScript will use the browser's time zone and display a date as a full text string.Date objects in JavaScript
Date objects in JavaScript are created with the new Date() constructor. The new Date() creates a new date object with the current date and time. It has a lot of methods and how you use it will depend on the format of the date you want to get.Simple JavaScript Date operation
var today = new Date();
document.getElementById("demo").innerHTML = "Today is: " + today;

var currentDate = new Date()
var day = currentDate.getDate()
var month = currentDate.getMonth() + 1
var year = currentDate.getFullYear()
document.getElementById("demo").innerHTML = "Today is: " + day + "/" + month + "/" + year;


Using Date.prototype.toLocaleDateString()
The toLocaleDateString() method returns a string with a language sensitive representation of the date portion of the specified date in the user agent's timezone.
today = new Date().toLocaleDateString()
document.getElementById("demo").innerHTML = "Today is: " + today;

Using Date.prototype.toISOString()
The toISOString() method returns a date object as a string, using the ISO standard. The standard is called ISO-8601 and the format is: YYYY-MM-DDTHH:mm:ss.sssZ.
today = new Date().toISOString().slice(0, 10)
document.getElementById("demo").innerHTML = "Today is: " + today;

Detailed date format
You can try this detailed date format like day name , month name etc.
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var objToday = new Date(),
weekday = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'),
dayOfWeek = weekday[objToday.getDay()],
domEnder = function() { var a = objToday; if (/1/.test(parseInt((a + "").charAt(0)))) return "th"; a = parseInt((a + "").charAt(1)); return 1 == a ? "st" : 2 == a ? "nd" : 3 == a ? "rd" : "th" }(),
dayOfMonth = today + ( objToday.getDate() < 10) ? '0' + objToday.getDate() + domEnder : objToday.getDate() + domEnder,
months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'),
curMonth = months[objToday.getMonth()],
curYear = objToday.getFullYear();
var today = dayOfWeek + " " + dayOfMonth + " of " + curMonth + ", " + curYear;
document.getElementById("demo").innerHTML = "Today is: " + today;
</script>
</body>
</html>
Finally, you can use a single line code using JSON for getting the current date.
today = new Date().toJSON().slice(0,10).replace(/-/g,'/');
document.getElementById("demo-6").innerHTML = "Today is: " + today;

Related Topics
- JavaScript Popup Boxes
- Opening a new window in JavaScript
- How to Create Drop-Down Lists in JavaScript
- How do I include a JavaScript file in another JavaScript file?
- Print the content of a Div using JavaScript/jQuery
- How to get the current URL using JavaScript ?
- How to Detect a Mobile Device with JavaScript/jQuery
- How to validate an email address in JavaScript
- JavaScript Array Iteration
- How to Remove a Specific Item from an Array in JavaScript
- What is JavaScript closures?
- How To Remove a Property from a JavaScript Object
- How to get selected value from Dropdown list in JavaScript
- How to Open URL in New Tab | JavaScript
- How to delay/wait/Sleep in code execution | JavaScript
- How to round to at most 2 decimal places | JavaScript
- How to convert string to boolean | JavaScript
- How to check undefined in JavaScript?
- How To Copy to Clipboard | JavaScript
- How to encode a URL using JavaScript?
- How to force Input field to enter numbers only | JavaScript
- How to create multiline string in JavaScript
- How to Check for an Empty String in JavaScript?