Get Current Date and Time in JavaScript
Write a program to get the current date and time from the system in JavaScript.
Solution
To get the current date and time from the system in JavaScript, use new Date()
constructor. The constructor with no arguments passed returns a string with the current date and time.
Program
1. Get the current date by creating a Date object using the default constructor.
let currentDate = new Date();
console.log(currentDate);