您现在的位置: 万盛学电脑网 >> 程序编程 >> 脚本专题 >> javascript >> 正文

JavaScript将当前时间转换成UTC标准时间的方法

作者:佚名    责任编辑:admin    更新时间:2022-06-22

 这里使用JavaScript将当前时间转换成UTC标准时间,北京在东八区,在北京时间基础上减掉8小时

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 <!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>