zoukankan      html  css  js  c++  java
  • js 处理日期

    var CountTime = 2 * 60 * 1000;
    var Countdown = CountTime;
    
    function RefreshTime() {
        var dataObj = new Date();
        dataObj.setTime(Countdown);
        $("#jsCountTime").html(dataObj.getMinutes() + "分钟" + dataObj.getSeconds() + "");
        Countdown = Countdown - 1000;
        if (Countdown <= 0) {
            if ($("#jsLastStatus").val() != GetDateString()) {
                MonitorAjax();
            }
            Countdown = CountTime;
            $("#jsLastStatus").val(GetDateString());
        }
    
        window.setTimeout(function () {
            RefreshTime();
        }, 1000);
    }
    function GetDateString() {
        var dateTime = new Date();
        var year = dateTime.getYear(); //获取当前年份(2位)  
        var moonth = dateTime.getMonth(); //获取当前月份(0-11,0代表1月)  
        var day = dateTime.getDay(); //获取当前星期X(0-6,0代表星期天)
        var hour = dateTime.getHours();
        return year + "" + moonth + "" + day + "" + hour;
    }
    function NowTime() {
        var nowDate = new Date();
        var week;
        if (new Date().getDay() == 0) week = "星期日"
        if (new Date().getDay() == 1) week = "星期一"
        if (new Date().getDay() == 2) week = "星期二"
        if (new Date().getDay() == 3) week = "星期三"
        if (new Date().getDay() == 4) week = "星期四"
        if (new Date().getDay() == 5) week = "星期五"
        if (new Date().getDay() == 6) week = "星期六"
        var Nowtime = nowDate.getFullYear() + "-" + (nowDate.getMonth()+1) + "-" + nowDate.getDate() + "&nbsp;&nbsp; " + week;
        $("#jsnowtime").html(Nowtime);
    }
    function numToArr(num)
    {
        var result = [];
        var num1 = num;
        while (num1 / 10 >= 1)
        {
            result.push(num1 % 10); num1 = parseInt(num1 / 10);
        }
        result.push(num1 % 10);
        for (var i = result.length; i < 4; i++) {
            result.push(0);
        }
        return result;
    }
  • 相关阅读:
    git 实践(二) push的使用
    git 实践(一) pull的使用
    redux项目实战应用笔录
    浅谈ES6的Object.assign()浅拷贝
    React下reducer中处理数组&&对象的赋值改动
    git pull与git clone
    (0)网络编程基础(网络基本知识)
    (1)什么是socket(套接字)
    (12)异常处理
    (11)类的内置函数
  • 原文地址:https://www.cnblogs.com/futengsheng/p/7001828.html
Copyright © 2011-2022 走看看