這篇文章主要介紹了JavaScript將當(dāng)前時(shí)間轉(zhuǎn)換成UTC標(biāo)準(zhǔn)時(shí)間的方法,涉及javascript中Date及toUTCString方法的使用技巧,需要的朋友可以參考下
本文實(shí)例講述了JavaScript將當(dāng)前時(shí)間轉(zhuǎn)換成UTC標(biāo)準(zhǔn)時(shí)間的方法。分享給大家供大家參考。具體如下:
這里使用JavaScript將當(dāng)前時(shí)間轉(zhuǎn)換成UTC標(biāo)準(zhǔn)時(shí)間,北京在東八區(qū),在北京時(shí)間基礎(chǔ)上減掉8小時(shí)
- <!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>
希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答
圖片精選