What is the use of the Date object in JavaScript ?
Last Updated :
30 Jan, 2024
The Date
object in JavaScript is used to work with dates and times. It provides methods for creating, manipulating, and formatting dates, making it a fundamental part of handling temporal data in web development. The Date
object represents a specific point in time, down to milliseconds, and allows developers to perform various operations related to dates and times.
Example: You can create a new Date
object to represent the current date and time or a specific date and time using various constructors.
Javascript
const currentDate = new Date();
const specificDate = new Date(2022, 0, 29, 12, 30, 0);
console.log(specificDate);
|
Output
2022-01-29T12:30:00.000Z
Share your thoughts in the comments
Please Login to comment...