Home >Web Front-end >JS Tutorial >JavaScript method to convert current time to UTC standard time_javascript skills

JavaScript method to convert current time to UTC standard time_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:05:321697browse

The example in this article describes how JavaScript converts the current time into UTC standard time. Share it with everyone for your reference. The details are as follows:

Here, JavaScript is used to convert the current time into UTC standard time. Beijing is in the East Eighth District, and 8 hours are subtracted 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 will be helpful to everyone’s JavaScript programming design.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn