Home » JavaScript

Date getUTCMonth() method with example in JavaScript

JavaScript Date getUTCMonth() method: Here, we are going to learn about the getUTCMonth() method of Date class with Example in JavaScript.
Submitted by IncludeHelp, on March 08, 2019

JavaScript Date getUTCMonth() method

getUTCMonth() method is a Date's class method and it is used to get the current month’s value according to the UTC (Universal time coordinated) between the range of 0 to 11, where 0 for January, 1 for February, ..., 11 for December.

Syntax:

    var dt = new Date();
    dt.getUTCMonth();

Examples:

    Input:
    var dt = new Date();
    dt.getUTCMonth();
    
    Output:
    2 //if the month is March

JavaScript code to get the current UTC month's value using getUTCMonth() method

<html>
<head><title>JavaScipt Example</title></head>

<body>
<script>
	var dt = new Date(); //Date constructor 
	var month1 = dt.getUTCMonth(); //UTC Month
	var month2 = dt.getMonth(); //local Month
	//printing Milliseconds
	document.write("UTC Month = " + month1 + "<br>");
	document.write("Local Month = " + month2 + "<br>");
</script>
</body>
</html>

Output

UTC Month = 2
Local Month = 2

Reference: JavaScript getUTCMonth() Method






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.