Home >>JavaScript Date Object Methods >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()
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
toUTCString() | Yes | Yes | Yes | Yes | Yes |
<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>
<html> <body> <script> var date=new Date(1997, 0, 5, 18, 25, 17); document.writeln(date.toUTCString()); </script> </body> </html>