• time


    ///$.twoDates("startdate",'enddate',3);
    $.extend({
        setTwoDates: function (startinputid, endinputid, difference) {
    
            var year = 0;
            var today = "";
            var mydate = new Date();
            var mymonth = mydate.getMonth() + 1;
            var myday = mydate.getDate();
            var myyear = mydate.getFullYear();
            year = (myyear > 200) ? myyear : 1900 + myyear;
            if (mymonth >= 10) { mymonth = mymonth; } else { mymonth = "0" + mymonth; }
            if (myday >= 10) { myday = myday; } else { myday = "0" + myday; }
            today = year + '-' + mymonth + '-' + myday;
    
            $("#" + endinputid).val(today);
    
            var enddate = mydate.valueOf();
            enddate = enddate - difference * 24 * 60 * 60 * 1000;
            mydate = new Date(enddate);
    
            var year = 0;
            var today = "";
            var mymonth = mydate.getMonth() + 1;
            var myday = mydate.getDate();
            var myyear = mydate.getFullYear();
            year = (myyear > 200) ? myyear : 1900 + myyear;
            if (mymonth >= 10) { mymonth = mymonth; } else { mymonth = "0" + mymonth; }
            if (myday >= 10) { myday = myday; } else { myday = "0" + myday; }
            today = year + '-' + mymonth + '-' + myday;
    
            $("#" + startinputid).val(today);
    
    
        }
    })
    
    ///$("#elementid").setDefaultDate();
    
    $.fn.extend({
        setDefaultDate: function (datetype) {
            var day = 0;
            var month = 0;
            var year = 0;
            var today = "";
            mydate = new Date();
            mydate.setTime(mydate.getTime() - 24 * 60 * 60 * 1000);
            mymonth = mydate.getMonth()+1;
            myday = mydate.getDate();
            myyear = mydate.getFullYear();
            year = (myyear > 200) ? myyear : 1900 + myyear;
            if (mymonth >= 10) { mymonth = mymonth; } else { mymonth = "0" + mymonth; }
            if (myday >= 10) { myday = myday; } else { myday = "0" + myday; }
            switch (datetype)
            {
                case "day":
                    today = year + '-' + mymonth + '-' + myday;
                    break;
                case "month":
                    today = year + '-' + mymonth;
                    break;
                case "year":
                    today = year;
                default:
                    break;
            }
    
            $(this).val(today);
        }
    })
  • 相关阅读:
    STL容器内数据删除
    grep 同时满足多个关键字和满足任意关键字
    程序运行栈空间不足程序崩溃问题
    VS2010中设置程序以管理员身份运行
    python 包详解
    select 详解
    Hdu 1166
    CF1204C
    CF1204B
    CF1204A
  • 原文地址:https://www.cnblogs.com/rage-the-dream/p/6526787.html
Copyright © 2020-2023  润新知