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
Release: 2016-05-16 16:05:32
Original
1700 people have browsed it

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>
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template