Date Get Methods in JavaScript

In JavaScript there are some methods to get date information.

There is a list of JavaScript get date methods with their description.

Methods Description
getDate() This method is used to returns the integer value between 1 and 31 that represents the day for the specified date on the basis of local time in JavaScript.
getDay() This method is used to returns the integer value between 0 and 6 that represents the day of the week on the basis of local time in JavaScript.
getFullYears() This method is used to returns the integer value that represents the year on the basis of local time in JavaScript.
getHours() This method is used to returns the integer value between 0 and 23 that represents the hours on the basis of local time in JavaScript.
getMilliseconds() This method is used to returns the integer value between 0 and 999 that represents the milliseconds on the basis of local time in JavaScript.
getMinutes() This method is used to returns the integer value between 0 and 59 that represents the minutes on the basis of local time in JavaScript.
getMonth() This method is used to returns the integer value between 0 and 11 that represents the month on the basis of local time in JavaScript.
getSeconds() This method is used to returns the integer value between 0 and 60 that represents the seconds on the basis of local time in JavaScript.
getUTCDate() This method is used to returns the integer value between 1 and 31 that represents the day for the specified date on the basis of universal time in JavaScript.
getUTCDay() This method is used to returns the integer value between 0 and 6 that represents the day of the week on the basis of universal time in JavaScript.
getUTCFullYears() This method is used to returns the integer value that represents the year on the basis of universal time in JavaScript.
getUTCHours() This method is used to returns the integer value between 0 and 23 that represents the hours on the basis of universal time in JavaScript.
getUTCMinutes() This method is used to returns the integer value between 0 and 59 that represents the minutes on the basis of universal time in JavaScript.
getUTCMonth() This method is used to returns the integer value between 0 and 11 that represents the month on the basis of universal time in JavaScript.
getUTCSeconds() This method is used to returns the integer value between 0 and 60 that represents the seconds on the basis of universal time in JavaScript.

Example of getTime() Method

In this example getTime() used to display the number of milliseconds since January 1, 1970:

<script type = "text/javascript">
var d = new Date();
document.write(d.getTime()); 
</script>                  
        

Output of above code


Example of getFullYear() Method

In this example getFullYear() method us used to diplay the year of a date as a four digit number:

<script type = "text/javascript">
var d = new Date();
document.write(d.getFullYear());
</script>                  
        

Output of above code


Example of getMonth() Method

In this example getMonth() method us used to display the month of a date as a number (0-11):

<script type = "text/javascript">
var d = new Date();
document.write(d.getMonth() + 1);
</script>                  
        

Output of above code


Example of getDate() Method

In this example getDate() method is used to display the day of a date as a number (1-31):

<script type = "text/javascript">
var d = new Date();
document.write(d.getDate());
</script>                  
        

Output of above code


Example of getHours() Method

In this example getHours() method is used to display the hours of a date as a number (0-23):

<script type = "text/javascript">
var d = new Date();
document.write(d.getHours());
</script>                  
        

Output of above code


Example of getMinutes() Method

In this example getMinutes() method is used to display the minutes of a date as a number (0-59):

<script type = "text/javascript">
var d = new Date();
document.write(d.getMinutes());
</script>                  
        

Output of above code


Example of getSeconds() Method

In this example getSeconds() method is used to display the seconds of a date as a number (0-59):

<script type = "text/javascript">
var d = new Date();
document.write(d.getSeconds());
</script>                  
        

Output of above code


Example of getMilliseconds() Method

In this example getMilliseconds() method is used to display the milliseconds of a date as a number (0-999):

<script type = "text/javascript">
var d = new Date();
document.write(d.getMilliseconds());
</script>                  
        

Output of above code








The Best

Comment here

If you have any query, if you want to know something about any of technical course related to computer science field, if you have any suggestion about relevant to uploaded content or if you anything wrong here (any mistake in content) than please contact us. Keep in mind, comment should be according to community guidelines.