⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utc.js

📁 这是《JavaScript学习源代码》一书的源代码
💻 JS
字号:
// create a new Date object
var now = new Date();

// get local time in hours
var hh = now.getHours();

// get the Universal time in hours
var utc_hh = now.getUTCHours();

// get minutes and seconds
var mn = now.getMinutes();
var ss = now.getSeconds();

// ensure there are two digits for the minute value
if( mn <= 9 ) mn = "0" +mn;  

// display both times
var wet = "Athens time: "+hh+": "+mn+": "+ss+"\n\n";
var utc = "Universal time: "+utc_hh+": "+mn+": "+ss;
alert( wet + utc );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -