Home » javascript » Data Object in JavaScript

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