zoukankan      html  css  js  c++  java
  • 时间js

    function Appendzero (obj) {
        if (obj < 10) return "0" + obj; else return obj;
    }
    function getWeek () {
       var weeknum = new Date().getDay ();
       var week = "";
       if (weeknum == 0)  week = "星期日";
       if (weeknum == 1)  week = "星期一";
       if (weeknum == 2)  week = "星期二";
       if (weeknum == 3)  week = "星期三";
       if (weeknum == 4)  week = "星期四";
       if (weeknum == 5)  week = "星期五";
       if (weeknum == 6)  week = "星期六";
       return week;
    }
    function getDate(){
       var now = new Date ();
       var year = now.getFullYear ();//获取四位数年数
       var month = now.getMonth () + 1;
       var date = now.getDate ();
       var s = year + "-" + Appendzero (month) + "-" + Appendzero (date) 
       return s;
    }
    function getTime(){
        var now = new Date ();
        var hour = now.getHours ();
        var minute = now.getMinutes ();
        var second = now.getSeconds ();
        var s = Appendzero (hour) + ":" + Appendzero (minute) + ":" + Appendzero (second);
        return s;
    }
    function getTime2(){
        var now = new Date ();
        var hour = now.getHours ();
        var minute = now.getMinutes ();
        var s = Appendzero (hour) + ":" + Appendzero (minute)
        return s;
    }
    //设置动态时间
    function setTime1(id){
          document.getElementById("id").innerHTML = getTime2();
         window.setTimeout("setTime("+id+")", 1000);
    }
    //设置动态时间
    function setTime2(id){
          document.getElementById("id").innerHTML = getTime1();
         window.setTimeout("setTime("+id+")", 1000);
    }
  • 相关阅读:
    随笔
    梨花落(短篇小说)
    javascript中的apply,call,bind详解
    js中this的指向问题
    你若安好,便是晴天
    gulp
    图标
    normalize.css
    git bash和toritoise客户端结合使用
    云计算基础知识
  • 原文地址:https://www.cnblogs.com/beimingbingpo/p/8780799.html
Copyright © 2011-2022 走看看