• JavaScript—当前时间


    当前时间-倒计时下载

    效果:

    代码:

    <!doctype html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>倒计时js代码</title>
        <style>
            *
            {
                margin: 0;
                padding: 0;
                list-style: none;
            }
            body
            {
                font-size: 18px;
                text-align: center;
            }
            .time
            {
                height: 30px;
                padding: 200px;
            }
        </style>
    </head>
    <body>
        </div>
        <!--当前时间-->
        <div id="show">
        </div>
    </body>
    
    <script>//当前时间
        window.onload = function() {
            var show = document.getElementById("show");
            setInterval(function() {
                var time = new Date();
                // 程序计时的月从0开始取值后+1
                var m = time.getMonth() + 1;
                var t = time.getFullYear() + "-" + m + "-" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
                show.innerHTML = t;
            }, 1000);
        };
    </script>
    
    </html>

    动态显示当前时间,带日期

    效果:

    代码:

    //动态显示当前的时间
        function GetTime(obj) {
            var myDate = new Date();
            var Today = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
            //获取当前年
            var Years = myDate.getFullYear();
            //获取当前月
            var Months = myDate.getMonth() + 1;
            //获取当前日
            var Dates = myDate.getDate();
    
            //获取当前天是当前周的第几天
            var Days = Today[myDate.getDay()];
    
            //获取当前的时
            var Hours = myDate.getHours();
            //获取当前的分
            var Minutes = myDate.getMinutes();
            //获取当前的秒
            var Seconds = myDate.getSeconds();
    
            Months = Months < 10 ? "0" + Months : Months;
            Dates = Dates < 10 ? "0" + Dates : Dates;
    
            Hours = Hours < 10 ? "0" + Hours : Hours;
            Minutes = Minutes < 10 ? "0" + Minutes : Minutes;
            Seconds = Seconds < 10 ? "0" + Seconds : Seconds;
    
            return Years + "年" + Months + "月" + Dates + "日" + " " + Days + " " + Hours + ":" + Minutes + ":" + Seconds;
        }
    
        function showTitleInfo() {
            document.getElementById("dateInfo").innerHTML = GetTime();
            setTimeout("showTitleInfo()", 1000);
        }
        showTitleInfo();
  • 相关阅读:
    Android NDK 开发中 adb logcat 命令的使用
    android 工程里缺少 R.java 文件原因和解决方法
    用Linux命令行实现删除和复制指定类型的文件
    重载操作符与转换
    复制控制
    管理类的指针成员
    复制构造函数
    static类成员(变量和函数)
    lock failed, MQ already started 问题处理
    Mac无法启动RocketMQ,日志显示,runserver.sh: line 91: /Library/Internet: No such file or directory
  • 原文地址:https://www.cnblogs.com/cang12138/p/6211840.html
Copyright © 2020-2023  润新知