zoukankan      html  css  js  c++  java
  • 双日历时间段选择控件—daterangepicker(汉化版)

    daterangepicker的配置信息,记录下来方便设置:

    <pre name="code" class="html"><pre name="code" class="javascript"><script type="text/javascript">
            $(document).ready(function (){
                        //时间插件
                        $('#reportrange span').html(moment().subtract('hours', 1).format('YYYY-MM-DD HH:mm:ss') + ' - ' + moment().format('YYYY-MM-DD HH:mm:ss'));
            
                        $('#reportrange').daterangepicker(
                                {
                                    // startDate: moment().startOf('day'),
                                    //endDate: moment(),
                                    //minDate: '01/01/2012',    //最小时间
                                    maxDate : moment(), //最大时间 
                                    dateLimit : {
                                        days : 30
                                    }, //起止时间的最大间隔
                                    showDropdowns : true,
                                    showWeekNumbers : false, //是否显示第几周
                                    timePicker : true, //是否显示小时和分钟
                                    timePickerIncrement : 60, //时间的增量,单位为分钟
                                    timePicker12Hour : false, //是否使用12小时制来显示时间
                                    ranges : {
                                        //'最近1小时': [moment().subtract('hours',1), moment()],
                                        '今日': [moment().startOf('day'), moment()],
                                        '昨日': [moment().subtract('days', 1).startOf('day'), moment().subtract('days', 1).endOf('day')],
                                        '最近7日': [moment().subtract('days', 6), moment()],
                                        '最近30日': [moment().subtract('days', 29), moment()]
                                    },
                                    opens : 'right', //日期选择框的弹出位置
                                    buttonClasses : [ 'btn btn-default' ],
                                    applyClass : 'btn-small btn-primary blue',
                                    cancelClass : 'btn-small',
                                    format : 'YYYY-MM-DD HH:mm:ss', //控件中from和to 显示的日期格式
                                    separator : ' to ',
                                    locale : {
                                        applyLabel : '确定',
                                        cancelLabel : '取消',
                                        fromLabel : '起始时间',
                                        toLabel : '结束时间',
                                        customRangeLabel : '自定义',
                                        daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
                                        monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月',
                                                '七月', '八月', '九月', '十月', '十一月', '十二月' ],
                                        firstDay : 1
                                    }
                                }, function(start, end, label) {//格式化日期显示框
                                    
                                     $('#reportrange span').html(start.format('YYYY-MM-DD HH:mm:ss') + ' - ' + end.format('YYYY-MM-DD HH:mm:ss'));
                               });
    
                //设置日期菜单被选项  --开始--
    /*
                        var dateOption ;
                        if("${riqi}"=='day') {
                            dateOption = "今日";
                      }else if("${riqi}"=='yday') {
                            dateOption = "昨日";
                      }else if("${riqi}"=='week'){
                            dateOption ="最近7日";
                      }else if("${riqi}"=='month'){
                            dateOption ="最近30日";
                      }else if("${riqi}"=='year'){
                            dateOption ="最近一年";
                      }else{
                            dateOption = "自定义";
                      }
                         $(".daterangepicker").find("li").each(function (){
                            if($(this).hasClass("active")){
                                $(this).removeClass("active");
                            }
                            if(dateOption==$(this).html()){
                                $(this).addClass("active");
                            }
                      });*/
                             //设置日期菜单被选项  --结束--
            })
        </script>

    效果图: 

    效果图

      

                                              --谨记铭心

  • 相关阅读:
    2019.2.18接口
    第一阶段复习
    vue-cli使用介绍
    Webpack 入门教程
    js报错Uncaught TypeError: Cannot read property 'getElementsByTagName' of null
    用shell编程.编写一个程序,用循环创建多个目录 并在该目录下创建多个文件 在文件中写入内容:
    explorer.exe应用程序错误,怎么解决?
    [Java连接MySQL数据库——含详细步骤和代码](https://www.cnblogs.com/town123/p/8336244.html)
    墨刀的简单使用
    laravel报错:SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY...
  • 原文地址:https://www.cnblogs.com/xinloverong/p/5868318.html
Copyright © 2011-2022 走看看