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);
    }
  • 相关阅读:
    [bzoj4408][Fjoi2016]神秘数
    BZOJ1102: [POI2007]山峰和山谷Grz
    BZOJ1098: [POI2007]办公楼biu
    BZOJ1097: [POI2007]旅游景点atr
    GDOI2018 新的征程
    BZOJ2084: [Poi2010]Antisymmetry
    回文树详解
    Codeforces739E. Gosha is hunting
    一道题17
    LOJ#6002. 「网络流 24 题」最小路径覆盖
  • 原文地址:https://www.cnblogs.com/beimingbingpo/p/8780799.html
Copyright © 2011-2022 走看看