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);
    }
  • 相关阅读:
    blocksit.js插件瀑布流
    防止点浏览器返回按钮,返回上一页的JS方法
    jquery 换肤功能
    HTML5获取地理位置
    百度api定位
    网站如何做到完全不需要使用jQuery
    让网页变成灰色代码
    利用html标签限制搜索引擎对网站的抓取收录
    高清ICON SVG解决方案
    加载动画
  • 原文地址:https://www.cnblogs.com/beimingbingpo/p/8780799.html
Copyright © 2011-2022 走看看