JavaScript Tutorial

Javascript Date Get Methods

There are different methods for getting information from a date object.

getMonth() method

This method is used to fetch the month(0 to 11) from given Date object. This function does not accept any parameter.

Input:-

Output:-

getDate() method

This method is used to fetch the date of a month from a given Date object. This method does not takes any parameter. It is just used along with a Date Object from which we want to fetch the date of the month.

Input:-

Output:-

getHours() method

This method is used to return the hours from a given Date object. This method does not accept any parameter.

Input:-

Output:-

getMinutes() method

This method is used to fetch the minutes from given Date object. This function does not accept any parameter.

It returns the minutes for the given Date Object. Minutes is an integer value ranging from 0 to 59.

Input:-

Output:-

getSeconds() method

This method is used to fetch the seconds from given Date object. This function does not accept any parameter. It returns the second for the given date object. Seconds is an integer value ranging from 0 to 59.

Input:-

Output:-

getMilliseconds() method

This method is used to fetch the milliseconds from a given Date object. This function does not accept any parameter. It returns the millisecond for the given date object. Milliseconds is an integer value ranging from 0 to 999.

Input:-

Output:-

getDay() method

This method is used to fetch the day of a week(0 to 6) from a given Date object. This function does not accept any parameter. It returns the day of the week for the given date. Day of the week will be returned in the form of integer value ranging from 0 to 6 means 0 for Sunday, 1 for Monday, and so on till 6 for Saturday.

Input:-

Output:-

getFullYear() method

This method is used to fetch the year from a given Date object. This function does not accept any parameter. It returns the year for the given date.

Input:-

Output:-

getTime() method

This method used to returns the number of milliseconds since 1 January 1970. when a new Date object is created it stores the date and time data when it is created. This method does not accept any parameter.

Input:-

Output:-

Go back to Previous Course