Skip to content
Related Articles

Related Articles

JavaScript Date Object Complete Reference

Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 21 Nov, 2022
Improve Article
Save Article

The Date object in JavaScript is used to represent a moment in time. It is used to work with date and time. This time value is since 1 January 1970 UTC (Coordinated Universal Time). 

 

Syntax:

new Date();

Example 1: If nothing as the parameter is given, it returns the present date and time.

Javascript




<script>
    // If nothing as a parameter is given,
    // it represents the present date and time.
    var A = new Date();
      
    // Printing present date and time.
    console.log(A);
</script>


Output:

Mon Nov 14 2022 16:56:38 GMT+0530 (India Standard Time)

The complete list of JavaScript properties and functions & properties are listed below:

Properties:

JavaScript  Date Object Properties

Description

JavaScript  Date.constructor Property The Date constructor property returns the constructor function for an object.
JavaScript Date.prototype property The date.prototype property represents the prototype for the Date constructor.

Functions:

JavaScript  Date Object Functions

Description 

JavaScript date.getDate() Function The date.getDate() method is used to fetch the date of a month from a given Date object.
JavaScript date.getDay() Function The Date.getDay() method is used to fetch the day of a week(0 to 6) from a given Date object.
JavaScript date.getFullYear() Function The date.getFullYear() method is used to fetch the year from a given Date object
JavaScript date.getHours() Function The date.getHours() method is used to return the hours from a given Date object.
JavaScript date.getMilliseconds() Function The date.getMilliseconds() method is used to fetch the milliseconds from a given Date object.
JavaScript date.getMinutes() Function The date.getMinutes() method is used to fetch the minutes from the given Date object. 
JavaScript date.getMonth() Function The date.getMonth() method is used to fetch the month(0 to 11) from the given Date object.
JavaScript date.getSeconds() Function The date.getSeconds() method is used to fetch the seconds from the given Date object.
JavaScript  date.getTime() Function The date.getTime() method is used to return the number of milliseconds since 1 January 1970. 
JavaScript date.getTimezoneOffset() Function The date.getTimezoneOffset() method is used to return the time difference between Universal Coordinated Time (UTC) and local time, in minutes.
JavaScript date.getUTCDate() Function The date.getUTCDate() method is used to fetch the date of a month according to universal time from a given Date object.
JavaScript date.getUTCDay() Function The date.getUTCDay() method is used to fetch the date of a month according to universal time from a given Date object.
JavaScript date.getUTCFullYear() Function The date.getUTCFullYear() method is used to fetch the year according to universal time from a given Date object.
JavaScript date.getUTCHours() Function The date.getUTCHours() method is used to fetch the hours according to universal time from a given Date object.
JavaScript date.getUTCMilliseconds() Function The date.getUTCMilliseconds() method is used to fetch the millisecond according to universal time from a given Date object.
JavaScript date.getUTCMinutes() Function The date.getUTCMinutes() method used to fetch the minutes according to universal time from a given Date object.
JavaScript date.getUTCMonth() Function The date.getUTCMonth() method is used to fetch the month according to universal time from a given Date object.
JavaScript date.getUTCSeconds() Function The date.getUTCSeconds() method is used to fetch the second according to universal time from a given Date object.
JavaScript Date.now() Function The date.now() method is used to return the number of milliseconds elapsed since January 1, 1970, 00:00:00 UTC.
JavaScript Date.parse() Function The date.parse() method is used to know the exact number of milliseconds that have passed since midnight, January 1, 1970, till the date we provide.
JavaScript date.setDate() Function The date.setDate() method is used to set date of a month into a date object which is created using date() constructor. 
JavaScript date.setFullYear() Function The date.setFullYear() method is used to set year into a date object which is created using Date() constructor.
JavaScript date.setHours() Function The date.setHours() method is used to set hours into a date object which is created using the Date() constructor.
JavaScript  date.setMilliseconds() Function The date.setMilliseconds() method is used to set milliseconds into a date object which are created using date() constructor.
JavaScript date.setMinutes() Function The date.setMinutes() method is used to set minutes into a Date object which is created using Date() constructor.
JavaScript date.setMonth() Function The date.setMonth() method is used to set month into a date object which is created using the Date() constructor.
JavaScript date.setSeconds() Function The date.setSeconds() method is used to set seconds into a Date object which is created using Date() constructor.
JavaScript date.setUTCDate() Function The date.setUTCDate() method is used to set date of a month according to universal time into a date object which are created using the Date() constructor.
JavaScript date.setUTCFullYear() Function The date.setUTCFullYear() method is used to set year into a date object according to universal time which is created using date() constructor.
JavaScript date.setUTCHours() Function The date.setUTCHours() method is used to set hours into a date object according to universal time which is created using the Date() constructor.
JavaScript date.setUTCMilliseconds() Function The date.setUTCMilliseconds() method is used to set milliseconds according to universal time into a date object which is created using Date() constructor.
JavaScript date.setUTCMinutes() Function The date.setUTCMinutes() method is used to set minutes according to universal time into a date object which is created using the Date() constructor.
JavaScript | date.setUTCMonth() method The date.setUTCMonth() method is used to set month according to universal time into a date object which is created using date() constructor. 
JavaScript | date.setUTCSeconds() Function The date.setUTCSeconds() method is used to set seconds according to universal time into a date object which is created using Date() constructor.
JavaScript date.toDateString() Function The date.toDateString() method is used to convert the given date object’s contents of date portion into a string. The date object is created using date() constructor.
JavaScript date.toISOString() Function The date.toISOString() method is used to convert the given date object’s contents into a string in ISO format (ISO 8601)
JavaScript date.toJSON() Function The date.toJSON() method is used to convert the given date object’s contents into a string. The date object is created using date() constructor.
JavaScript date.toLocaleDateString() Function The date.toLocaleDateString() method is used to convert a date to a string.
JavaScript date.toLocaleTimeString() Function The date.toLocaleTimeString() method is used to fetch the time from a given Date object.
JavaScript date.toLocaleString() Function The date.toLocaleString() method is used to convert a date and time to a string.
JavaScript date.toString() Function The date.toString() method is used to convert the given date object’s contents into a string. The date object is created using date() constructor.
JavaScript date.toTimeString() Function The date.toTimeString() method is used to return the time portion of the given date object in English. The date object is created using date() constructor.
JavaScript date.toUTCString() Function The date.toUTCString() method is used to convert the given date object’s contents into a string according to the universal time zone UTC. The date object is created using date() constructor.
JavaScript Date.UTC() Function The Date.UTC() method in JavaScript is used to return the number of milliseconds in a Date object since January 1, 1970, 00:00:00, universal time
JavaScript date.valueOf() Function The date.valueOf() method is used to get the number of milliseconds between 1 January 1970 00:00:00 UTC and the given date.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!