JavaScript Date functions

In this article, we will show the list of available JavaScript date functions that work on dates and times. We can use these built-in functions to get or set dates and times. Apart from this, we can use these date methods to convert the date and time or part of them to a string format in a human-readable format. Among the list, use the regular function (without UTC) for the local time zone and UTC functions for the Coordinated Time zone.

JavaScript Date Functions

The following are the list of Js Date functions that are available to work with Date and time.

JavaScript Date FunctionsDescription
Date()
Returns the Todays date and time
Date.Now()Current Date and time
getFullYear()Returns the year from the specified date accroding to the local time
getYear()
getMonth()This returns the Month from the specified date according to local tkime.
getDate()Returns Day of the Month from the specified date according to local time.
getDay()Returns Day of the Week from the specified date according to local time.
getTime()This returns the Number of Millisecond from January 1, 1970,  specified date according to local time.
getTimezoneOffset()
It returns the time zone difference between the local system time zone and UTC (Universal Coordinated Time) in minutes.
getHours()
Returns the Hours from the specified date according to local time.
getMinutes()
Returns Minutes from the specified date according to local time.
getSeconds()This returns the seconds in a specified date according to local time.
getMilliseconds()
It returns the Milliseconds value from a given date according to local time.
getUTCDate()
It returns the day of the month number between 1 and 31 on a given date according to UTC.
getUTCDay()
It returns the day of the week number between 0 (Sunday) and 6 (Saturday) on a given date according to UTC.
getUTCFullYear()
It returns the four-digit year number from a given date according to UTC.
getUTCHours()It returns the total hours between 0 and 23 on a given date according to UTC.
getUTCMinutes()
It returns the minutes value between 0 and 59 on a given date according to UTC.
getUTCMonth()
It returns the month number between 0 (January) and 11 (December) on a given date according to UTC.
getUTCSeconds()
It returns the seconds value between 0 and 59 on a given date according to UTC.
getUTCMilliseconds()It returns the milliseconds value between 0 and 999 on a given date according to UTC.
setFullYear()
Useful to set the full year, month, and day of a given date according to the local system time zone.
setMonth()
Useful to set the month number and day of a given date according to the local system time zone.
setDate()
Helpful to set the day of the month of a given date according to the local system time zone.
setTime()
It is used to set the time by adding or subtracting milliseconds to the default date, January 1, 1970, 00:00:00.
setHours()
It is used to set the Hours, Minutes, Seconds, and Milliseconds of a given date according to the local system time zone.
setMinutes()
It is used to set the Minutes, Seconds, and Milliseconds of a given date according to the local system time zone.
setSeconds()It is used to set the Seconds, and Milliseconds of a given date according to the local system time zone.
setMilliseconds()
It is used to set the Milliseconds of a given date according to the local system time zone.
setUTCFullYear()
Helpful to set the UTC full year, month, and day of a specified date according to the Universal Coordinated Time zone.
setUTCMonth()
Helpful to set the UTC month and day of a specified date according to the Universal Coordinated Time zone.
setUTCDate()
Useful to set the day of the month number of a specified date according to the Universal Coordinated Time zone.
setUTCHours()
It is used to set the UTC Hours, Minutes, Seconds, and Milliseconds of a given date according to the Universal Coordinated Time zone.
setUTCMinutes()It is used to set the UTC Minutes, Seconds, and Milliseconds of a given date according to the Universal Coordinated Time zone.
setUTCSeconds()
It is used to set the UTC Seconds, and Milliseconds of a given date according to the Universal Coordinated Time zone.
setUTCMilliseconds()
It is used to set the UTC Milliseconds of a given date according to the Universal Coordinated Time zone.
toDateString()
Returns the date portion from a given date in human-readable format according to the local system time zone.
toGMTString()
It converts the given date and time to a string according to Greenwich Mean Time (GMT).
toLocaleDateString()It converts the date portion from a given date to a string according to the local system time zone.
toLocaleTimeString()
It converts the time portion from a given time to a string according to the local system time zone.
toTimeString()
Returns the time portion from a given date and time in human-readable format according to the local system time zone.
toLocaleString()
It converts the given date and time to a string using the system locale conversion.
toString()It returns the string representation of the current date and time according to the local system time zone.
toUTCString()According to UTC zone, it converts the given date and time to a string format.
toISOString()Useful to return a string representation of the given date and time in ISO 8601 simplified format.

TIP: For more built-in methods, please refer to the string functions, HTML Wrapper functions, and Math functions in JavaScript.