To manipulate JavaScript’s Date object, you can either use get or set method and properties. For example, to set hours or to get minutes in JavaScript.
Once a Date object is created, a number of methods allow you to operate on it. Most methods simply allow you to get and set the year, month, day, hour, minute, second, and millisecond fields of the object, using either local time or UTC (universal, or GMT) time.
Here is a list of the methods used to Date and their description.
Sr.No | Method & Description |
---|---|
1 | date() Returns today's date and time |
2 | getDate() Returns the day of the month for the specified date according to local time. |
3 | getDay() Returns the day of the week for the specified date according to local time |
4 | getFullYear() Returns the year of the specified date according to local time. |
5 | getHours() Returns the hour in the specified date according to local time. |
6 | getMilliseconds() Returns the milliseconds in the specified date according to local time. |
7 | getMinutes() Returns the minutes in the specified date according to local time. |
8 | getMonth() Returns the month in the specified date according to local time. |
9 | getSeconds() Returns the seconds in the specified date according to local time. |
10 | setDate() Sets the day of the month for a specified date according to local time. |
11 | setFullYear() Sets the full year for a specified date according to local time. |
12 | setHours() Sets the hours for a specified date according to local time. |
13 | setMilliseconds() Sets the milliseconds for a specified date according to local time. |
14 | setMinutes() Sets the minutes for a specified date according to local time. |