Date toUTCString() Method - Javascript Date

Javascript examples for Date:toUTCString

Description

The toUTCString() method converts a Date object to a string, according to universal time.

UTC time is the same as GMT time.

Parameters

None

Return Value:

A String, representing the UTC date and time as a string

The following code shows how to Convert a Date object to a string, according to universal time:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from   www  .  j  a v a2  s  .c o  m*/
    var d = new Date();
    var n = d.toUTCString();
    document.getElementById("demo").innerHTML = n;
}
</script>

</body>
</html>

Related Tutorials