Data Object in JavaScript

The Date object is a datatype, Date objects are created with the new Date( ), Most of “Date” methods simply allow you to get and set the year, month, day, hour, minute, second.

If no arguments are provided, the constructor creates a JavaScript Date object for the current date and time according to system settings for timezone offset.

JavaScript can represent date and time till the year 275755.

Syntax

Date Properties

Date.properties-It will allows the addition of properties to a Date object.

Date.length– This property will find the length of date and display the value of Date.length. This is the number of arguments which is handled by the constructor.

Date Methods

Sr NoMathodDescription
1Date()It will return today’s date and time
2getDate()It will return the day of the month for the specified date as per local time.
3getDay()It will return the day of the week for the specified date as per local time.
4getFullYear()It will return the year of the specified date as per local time
5getHours()It will return the hour in the specified date as per local time.
6getMilliseconds()It will return the milliseconds in the specified date as per local time.
7getMinutes()It will return the minutes in the specified date as per local time
8getMonth()It will return the month in the specified date as per local time.
9getSeconds()It will return the seconds in the specified date as per local time.
10getTime()It will return the numeric value of the specified date as the number of milliseconds
11getTimezoneOffset()It will return the time-zone offset in minutes for the current locale
12getYear()It will returns the year in the specified date of local time
13setDate()It will sets the day of the month for a specified date of local time.
14setFullYear()It will set the full year for a specified date of local time.
15setHours()It will set the hours for a specified date of local time
16setMilliseconds()This method is forsets the milliseconds for a specified date of local time.
17setMinutes()This method is used to set the minutes for a specified date of local time
18setMonth()This method is used to set the month for a specified date of local time.
19setSeconds()This method is used to set the seconds for a specified date of local time.
20setTime()This method is used to set the Date object to the time represented by a number of milliseconds.