×

Index

JavaScript Tutorial

JavaScript Examples

CSS Tutorial

CSS Examples

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

JavaScript Examples »



Related Examples



Comments and Discussions!

Load comments ↻





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