getFullYear() Method
The getFullYear() method in JavaScript is used to return the year (in 4-digit) for the specified date according to local time.
Example: This example describes the getFullYear() method for retrieving the year from the date object.
JavaScript
let d = new Date(); console.log(d.getFullYear()); |
2023
JavaScript Get Date Methods
JavaScript Date Object allows us to get and set the date values.
In this article, we will know how to get the various date methods from the date object in Javascript. There are various methods that retrieve the date in JavaScript. The date values can get like years, months, days, hours, minutes, seconds, and milliseconds from a Date Object.
The following is the list of the date method to retrieve the various dates from the Date object in Javascript.
Methods:
- getDate(): It is used to get the day as a number (1-31).
- getFullYear(): It is used to get the year.
- getHours(): It is used to get the hour (0-23).
- getMilliseconds(): It is used to get the milliseconds (0-999).
- getMinutes(): It is used to get the minutes (0-59).
- getMonth(): It is used to get the month (0-11).
- getSeconds(): It is used to get the seconds (0-59).
- getTime(): It used to return the number of milliseconds since 1 January 1970.
- getDay(): It is used to get the weekday as a number (0-6).
- date.now(): It is used to return the number of milliseconds elapsed since January 1, 1970, 00:00:00 UTC.
We will implement the different date methods & understand their usage through the examples.