zoukankan      html  css  js  c++  java
  • datetimerangepicker配置及默认时间段展示

    <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'),  //这里配置的起止时间将会决定在ranges中默认选中哪个时间段
      endDate: moment(),  //这里配置的起止时间将会决定在ranges中默认选中哪个时间段,如果不配置起止时间,则默认展示为今天
      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>
    
    bootstrap的datetimerangepicker配置,参考自:http://www.jb51.net/article/92780.htm
  • 相关阅读:
    日志统计|2018年蓝桥杯B组题解析第八题-fishers
    螺旋折线|2018年蓝桥杯B组题解析第七题-fishers
    递增三元组|2018年蓝桥杯B组题解析第六题-fishers
    乘积尾零|2018年蓝桥杯B组题解析第三题-fishers
    明码|2018年蓝桥杯B组题解析第二题-fishers
    第几天|2018年蓝桥杯B组题解析第一题-fishers
    2016年蓝桥杯B组C/C++省赛(预选赛)题目解析
    2016年蓝桥杯B组C/C++省赛(预选赛)试题
    计蒜客习题:同余方程
    数论——同余方程
  • 原文地址:https://www.cnblogs.com/beileixinqing/p/7794190.html
Copyright © 2011-2022 走看看