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

📄 ex9-16.htm

📁 《JAVASCRIPT 动态网页编程实例手册》一书中的源代码
💻 HTM
字号:
    <html>
    <head><title>日期时间方法 </title></head>
    <body bgcolor="lightblue"><h2>日期与时间</h2>
    <script language="JavaScript">
        <!-- 
        var now = new Date();    // Now is an instance of a Date object
        document.write("<font size='+1'>");
        document.write("<b>本地时间:</b> " + now + "<br>");
        var hours=now.getHours();
        var minutes=now.getMinutes();
        var seconds=now.getSeconds();
        var millisecs=now.getMilliseconds();
        var year=now.getFullYear();
        var month=now.getMonth() + 1;  //调整为实际月份
        var day=now.getDate();
        document.write("<br>当前时间为:"+year+ "年" +month+"月"+day+"日 "+hours+":"
                       +minutes+":"+seconds+":"+ millisecs+"<br>");
        document.write("toDateString()结果: " + now.toDateString() + "<br>");
        document.write("toGMTString()结果: " + now.toGMTString() + "<br>");
        document.write("toLocaleDateString()结果: " + now.toLocaleDateString() + "<br>");
        document.write("toLocaleString()结果: " + now.toLocaleString() + "<br>");
        document.write("toLocaleTimeString()结果: " + now.toLocaleTimeString() + "<br>");
        document.write("toString()结果: " + now.toString() + "<br>");
        document.write("toTimeString()结果: " + now.toTimeString() + "<br>");
        document.write("toUTCString()结果: " + now.toUTCString() + "<br>");
        document.write("valueOf()结果: " + now.valueOf() + "<br>");                     
        //-->
    </script>
    </body>
    </html>

⌨️ 快捷键说明

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