Home » JavaScript

Date getUTCDay() method with example in JavaScript

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

JavaScript Date getUTCDay() method

getUTCDay() method is a Date's class method and it is used to get the current day of the week according to the UTC (Universal time coordinated). It returns the value between 0 to 6 based on the day. 0 for Sunday, 1 for Monday... 6 for Saturday.

Syntax:

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

Examples:

    Input:
    var dt = new Date();
    dt.getUTCDay();
    
    Output:
    8

JavaScript code to get the current UTC day of the week using getUTCDay() method

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

<body>
<script>
	var dt = new Date(); //Date constructor 
	var day1 = dt.getUTCDay(); //UTC day of the week 
	var day2 = dt.getDay(); //local day of the week 
	//printing day of the week
	document.write("UTC day = " + day1 + "<br>");
	document.write("Local day = " + day2 + "<br>");
</script>
</body>
</html>

Output

UTC day = 5
Local day = 5

Reference: JavaScript getUTCDay() 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.