Open In App

JavaScript Date Reference

Last Updated : 12 Jun, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report
News Follow

The JavaScript Date object is important for handling dates and times in web development. It provides various methods to create, manipulate, and format dates. Understanding the Date object and its methods allows you to work effectively with dates and times in your applications. This guide covers the key features and methods of the JavaScript Date object, helping you to manage date and time data efficiently.

Syntax:

new Date();

Example: If nothing as the parameter is given, it returns the present date and time.

JavaScript
// If nothing as a parameter is given,
// it represents the present date and time.
let A = new Date();

// Printing present date and time.
console.log(A);

Output:

Mon Nov 14 2022 16:56:38 GMT+0530 (India Standard Time)

The complete list of JavaScript Date methods and properties are listed below:

JavaScript Date Constructor: A constructor gets called when an object is created using the new keyword.

ConstructorDescriptionExamples
Date()Create a Date instance or return a string representing the current time.

JavaScript Date Properties: A JavaScript property is a member of an object that associates a key with a value.

  • Instance Properties: An instance property is a property that has a new copy for every new instance of the class.
PropertiesDescriptionExamples
constructorReturns the constructor function for an object.

JavaScript Date Methods: JavaScript methods are actions that can be performed on objects.

  • Static Method: If the method is called using the Date class itself then it is called a static method.