JavaScript converts the current time to UTC standard time


This example demonstrates how JavaScript converts the current time to UTC standard time. Share with you for your reference. The details are as follows:

Here, JavaScript is used to convert the current time to UTC standard time. Beijing is located in the east 8th district, so subtract 8 hours from Beijing time

<!DOCTYPE html>
<html>
<body>
<p id="demo">
Click the button to display the UTC date and time as a string.
</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
var d = new Date();
var x = document.getElementById("demo");
x.innerHTML=d.toUTCString();
}
</script>
</body>
</html>

I hope this article has been helpful to your javascript programming.