Get the current date in JavaScript
Question:
How to get the current date in JavaScript? Answer:
let now = new Date();
console.log('The current date is: ' + now);
Description:
JavaScript Date
objects represent a single moment in time in a platform-independent format. Date objects contain a Number that represents milliseconds since 1 January 1970 UTC.
The Date()
constructor creates a new Date
object with the actual time value.
Reference:
Date manual
Share "How to get the current date in JavaScript?"
Related snippets:
- Convert milliseconds to minutes and seconds
- Check if date is valid in JavaScript
- Generate random date with JavaScript
- Generate random date in a range with JavaScript
- Check if date is today
- Get month name from Date in JavaScript
- Get the current date in JavaScript
- Get difference between 2 dates in JavaScript
- Get yesterday's date in JavaScript
- Get tomorrow's date in JavaScript
Tags:
javascript, date, Technical term:
Get the current date in JavaScript