Home » JavaScript

Get current UTC Date in Date / Month / Year format in JavaScript

JavaScript getting the current UTC Date in DD/MM/YY format: Here, we are going to learn how to get the current UTC date in JavaScript in Date / Month / Year format?
Submitted by IncludeHelp, on March 04, 2019

Getting current UTC date in JavaScript

To get the current UTC date in JavaScript, we need to use three library functions of Date class,

  1. Date getDate() Method – It returns current UTC date (day of the month)
  2. Date getMonth() Method – It returns current UTC month of the year
  3. Date getFullYear() Method – It returns UTC current year in 4 digits format

Note: To call these functions, we need to create an object to the Date class using Date class constructor.

Examples:

    Date class constructor:
    var dt = new Date();

    Function calls:
    dt.getUTCDate();
    dt.getUTCMonth()+1;
    dt.getUTCFullYear();
    
    Output:
    8
    3
    2019

JavaScript code to get the current UTC date in Date / Month / Year format

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

<body>
<script>
	var dt = new Date(); //Date constructor 
	var dd = dt.getUTCDate();
	var mm = dt.getUTCMonth()+1;
	var yy = dt.getUTCFullYear();
	//printing date
	document.write("Current UTC date is= " + dd + "/" + mm + "/" + yy + "<br>");
</script>
</body>
</html>

Output

Current UTC date is= 8/3/2019





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.