• 时间的基本处理


    输出2017-03-05格式

    function getNowFormatDate() {
        var date = new Date();
        var seperator1 = "-";
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if(month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if(strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        currentdate = year + seperator1 + month + seperator1 + strDate;
        return currentdate;
    };
    getNowFormatDate();

    处理结束时间不小于开始时间

    var currentdate;
    function getNowFormatDate() {
        var date = new Date();
        var seperator1 = "-";
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if(month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if(strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        currentdate = year + seperator1 + month + seperator1 + strDate;
        return currentdate;
    };
    getNowFormatDate();
    $('.start_date_input').val(currentdate);
    $('.start_date').datetimepicker({
        format: 'yyyy-mm-dd',
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        minView: "month"
    });
    $('.end_date_input').val(currentdate);
    $('.end_date').datetimepicker({
        format: 'yyyy-mm-dd',
        language: 'zh-CN',
        weekStart: 1,
        todayBtn: 1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        minView: "month"
    });
    $('.date_input').on('change', function() {
        var $this = $(this);
        var thisValue = new Date($this.val()).valueOf(),
            anotherValue = new Date($('.date_input').not(this).val()).valueOf();
        if($this.is('.start_date_input')) {
            if(thisValue > anotherValue) {
                wxcepAlert('开始日期不能大于结束日期');
                $this.val('');
            }
        } else {
            if(thisValue < anotherValue) {
                wxcepAlert('开始日期不能大于结束日期');
                $this.val('');
            }
        }
    });
    日常所遇,随手而记。
  • 相关阅读:
    Serverless 动态博客开发趟“坑”记
    tsv与csv文件
    zypper
    source、sh、./三种执行方式对脚本变量的影响
    linux nm
    ldconfig
    cpio
    License简介
    rpm之spec文件
    使用rpmbuild制作rpm包
  • 原文地址:https://www.cnblogs.com/zhihou/p/8939990.html
Copyright © 2020-2023  润新知