Menu Close

JavaScript Date Get Methods

Hi, In this article we are going to learn all about JavaScript date get methods with the help of the examples. I’ll highly recommend you, before going through this article, please read the JavaScript date tutorial because in that we teach you how to create a date object using an example.

JavaScript date object provide lots of method will see one by one with the help of the example.

JavaScript Date Get Methods

JavaScript date object provide various method that are used to getting the information from the date object.

All the JavaScript date get methods available below.

Get MethodsDescription
getFullYear()Get the year as four-digit
getMonth()Get the month as a number ( 0-11 )
getDate()Get the day as a number ( 1-31 )
getDay()Get the weekday as number ( 0-6 )
getTime()Get the time (milliseconds since January 1, 1970)
getSeconds()Get the seconds as number ( 0-59 )
getMilliseconds()Get the milliseconds as number ( 0-999 )
getMinutes()Get the minute (0-59)
getHoures()Get the houres (0-23)

The getFullYear() Method

The getFullYear() method is used to get the year from date object.

Example:


var date = new Date();
console.log(`Full year is ${date.getFullYear}`);

The getMonth() Method

The getMonth() is used to get the month from date object.

Example:


var date = new Date();
console.log(`Month is ${date.getMonth}`);

The getDate() Method

The getDate() is used to get the day from the date object as number (1-31).

Example:


var date = new Date();
console.log(`Date is ${date.getDate}`);

The getDay() Method

The getDay() is used to get week day from the date object as number (0-6).

Example:


var date = new Date();
console.log(`Day is ${date.getDate}`);

The getTime() Method

The getTime() method is used to get the number of milliseconds.

Example:


var date = new Date();
console.log(`Time is ${date.getTime}`);

The getSeconds() Method

The getSeconds() is used to get the seconds from the date object.

Example:


var date = new Date();
console.log(`Second is ${date.getSeconds}`);

The getMinutes() Method

The getMinutes() is return the minutes from the date object.

Example:


var date = new Date();
console.log(`Minutes are ${date.getMinutes}`);

The getHoures() Method

The getHoures() method is used to get the total hours from the date object.

Example:


var date = new Date();
console.log(`Total hours are ${date.getHoures}`);

The getMilliseconds() Method

The getMilliseconds() is used to get the milliseconds from the date object.

Example:


var date = new Date();
console.log(`Milliseconds are ${date.getMilliseconds}`);

UTC Date Methods

UTC date methods are used for working with UTC dates (Universal Time Zone dates):

  • getUTCFullYear() is same as getFullYear()
  • getUTCMonth() is same as getMonth()
  • getUTCDate() is same as getDate()
  • getUTCDay() is same as getDay()
  • getUTCSeconds() is same as getSeconds()
  • getUTCMilliseconds() is same as getMilliseconds()
  • getUTCMinutes() is same as getMinutes()
  • getUTCHoures() is same as getHoures()

Summary

So, In this article, we have seen all about JavaScript date object methods with the help of the example.

JavaScript date get methods are going to be very helpful, when you want to get or fetch the information from JavaScript date object in your JavaScript code or project.

These all are the get method to get the information from the JavaScript date object.
If you like this article, please share and support us so that we are coming along with the brand new JavaScript tutorial.

JavaScript Date Object
JavaScript Date Set Methods

Related Posts