daterangepicker引用

html

<link href="{{asset('/assets/adminlte/plugins/daterangepicker/daterangepicker.css')}}" rel="stylesheet" />

<div class="col-md-2" >
    <input type="text" name="daterange" class="form-control" data-value="{{old('daterange')}}" placeholder="请输入提交时间"/>
</div>

javascript

<script src="{{asset('/assets/js/application_new.min.js')}}"></script>
<script src="{{asset('/assets/adminlte/plugins/daterangepicker/moment.min.js')}}" type="text/javascript"></script>
<script src="{{asset('/assets/adminlte/plugins/daterangepicker/daterangepicker.js')}}" type="text/javascript"></script>

<script>
        var columns = {
            startDate: startDate,
            endDate: endDate,
            "autoApply": false,
            "opens": "center",
            autoUpdateInput: false, //set did not auto update input
            locale:{
            format: "YYYY-MM-DD",
            separator: ' - ',
            applyLabel: '{{trans('确定')}}',
            cancelLabel: '{{trans('取消')}}',
            weekLabel: 'W',
            customRangeLabel: '{{trans('自定义日期范围')}}',
            daysOfWeek: moment.weekdaysMin(),
            monthNames: moment.monthsShort(),
            firstDay: moment.localeData().firstDayOfWeek()
            },
            ranges: {
            '今天': [moment(), moment()],
            '昨天': [moment().subtract(1, 'days'), moment().subtract(1,'days')],
            '过去7天': [moment().subtract(6, 'days'), moment()],
            '本月': [moment().startOf('month'), moment().endOf('month')]
            }
        };
        var start_at = $("input[name='start_at']"),end_at = $("input[name='end_at']"),daterange = $("input[name='date_range']");
        var startDate = start_at.val(),endDate = end_at.val();
        var daterange = $("input[name='date_range']");
        @if(Input::get('date_range'))
            daterange.val("{{Input::get('date_range')}}");
        @endif
        daterange.daterangepicker(columns).on('cancel.daterangepicker', function(ev, picker) {
            
        }).on('apply.daterangepicker', function(ev, picker) {
            $(this).focus();
            $(this).val(picker.startDate.format(picker.locale.format)+picker.locale.separator+picker.endDate.format(picker.locale.format));
            $(this).blur();
            picker.hide();
        });

        $(function(){
            $('input[name=daterange]').daterangepicker({
                timePicker: true,
                timePickerIncrement: 30,
                autoUpdateInput: false,
                locale: {
                    cancelLabel: 'Clear'
                }
            });
            $('input[name=daterange]').on('apply.daterangepicker', function(ev, picker){
                $(this).val(picker.startDate.format('YYYY/MM/DD hh:mm:ss') + ' - ' + picker.endDate.format('YYYY/MM/DD hh:mm:ss'));
            });
            $('input[name=daterange]').on('cancel.daterangepicker', function(ev, picker){
                $(this).val('');
            });
        });
</javascript>

 

参考链接:https://www.cnblogs.com/leijing0607/p/7698414.html

引用文件下载:https://pan.baidu.com/s/1o87RKIQ

引用文件官网下载:http://www.daterangepicker.com/

 

转载于:https://my.oschina.net/arin/blog/1603029

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值