条件搜索,layui时间插件

条件搜索,layui时间插件


html

startTime: $("#inputDate").val() != "" ? GetTime($("#inputDate").val().split(" - ")[0]) : "",
endTime: $("#inputDate").val() != "" ? GetTime($("#inputDate").val().split(" - ")[1]) : ""
<input type="text" class="form-control" id="inputDate" placeholder="请选择时间范围">           

js时间处理

startTime: $("#inputDate").val() != "" ? GetTime($("#inputDate").val().split(" - ")[0]) : "",
endTime: $("#inputDate").val() != "" ? GetTime($("#inputDate").val().split(" - ")[1]) : ""        

js

    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#inputDate', //指定元素
            type: 'date',
            range: true,
            done: function (value,date,endDate) {
                $("#inputDate").change();
            }
        });
    });

	//处理字符串时间为时间戳
    let StrToDateTime = (value)  => {
        if (value) {
            return (new Date(Date.parse(value.replace(/-/g, "/"))));
        }
        return value;
    };
    let GetTime = (s) => {
        return StrToDateTime(s).getTime();
    };             

猜你喜欢

转载自blog.csdn.net/qq_43639296/article/details/88969329
今日推荐