Home >>JavaScript Date Object Methods >JavaScript Date toUTCString() Method

JavaScript Date toUTCString() Method

JavaScript Date toUTCString() Method

JavaScript Date toUTCString() method in JavaScript is an inbuilt method which is used to returns the specified date object in the form of string according to the universal time convention (UTC).

Syntax:
Date.toUTCString()

Browser Support

Method Chrome Edge Firefox Safari Opera
toUTCString() Yes Yes Yes Yes Yes
Here is an Example of JavaScript toUTCString() Method:
<html>
<body>
<button onclick="myutcStr()">click me</button>
<p id="UTCStr"></p>
<script>
function myutcStr() 
{
  var z = new Date();
  var n = z.toUTCString();
  document.getElementById("UTCStr").innerHTML = n;
}
</script>
</body>
</html>
Output:

Example 2:
<html>
<body>
<script>
var date=new Date(1997, 0, 5, 18, 25, 17);
document.writeln(date.toUTCString());
</script>
</body>
</html>
Output:

No Sidebar ads