Date getUTCDate() method with example in JavaScript

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

JavaScript Date getUTCDate() method

getUTCDate() method is a Date's class method and it is used to get the current day of the month according to the UTC (Universal time coordinated).

Syntax:

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

Examples:

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

JavaScript code to get the current UTC day of the month using getUTCDate() method

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

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

Output

UTC day = 8
Local day = 8

Reference: JavaScript getUTCDate() Method

JavaScript Date Object Methods »




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.