Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Bootstrap-datetimepicker像今天一样添加自定义按钮_Javascript_Jquery_Html_Css_Twitter Bootstrap - Fatal编程技术网

Javascript Bootstrap-datetimepicker像今天一样添加自定义按钮

Javascript Bootstrap-datetimepicker像今天一样添加自定义按钮,javascript,jquery,html,css,twitter-bootstrap,Javascript,Jquery,Html,Css,Twitter Bootstrap,如何在bootstrap datetimepicker中添加像今天这样的自定义按钮 例如:一周前,昨天 目前,我找到了以下解决方案: $('#route-from-date').datetimepicker({ autoclose: true, language: 'pl' }); $('#route-to-date').datetimepicker({ autoclose:

如何在bootstrap datetimepicker中添加像今天这样的自定义按钮

例如:一周前,昨天


目前,我找到了以下解决方案:

        $('#route-from-date').datetimepicker({
            autoclose: true,
            language: 'pl'
        });
        $('#route-to-date').datetimepicker({
            autoclose: true,
            language: 'pl',
            //todayBtn: 'ok'
        });
        $('.datetimepicker tfoot').append('<tr><th colspan="7" class="today_">Dzisiaj</th></tr><tr><th colspan="7" class="yesterday">Wczoraj</th></tr><tr><th colspan="7" class=" week">Tydzień</th></tr>');
        $('.datetimepicker tfoot th').on('click',function(){
            var $th = $(this);
            var d = new Date();
            var fd,td;
            if($th.hasClass('yesterday')){
                d.setDate(d.getDate() - 1);
            }
            else if ($th.hasClass('week')){
                d.setDate(d.getDate() - 7);
                fd = d.getFullYear() + '-' + ((d.getMonth()<10)?  '0'+(d.getMonth()+1) : d.getMonth()+1  ) + '-' + ((d.getDate()<10)?  '0'+d.getDate() : d.getDate()  ) + ' 00:00';
                d.setDate(d.getDate() + 7);
                td = d.getFullYear() + '-' + ((d.getMonth()<10)?  '0'+(d.getMonth()+1) : d.getMonth()+1  ) + '-' + ((d.getDate()<10)?  '0'+d.getDate() : d.getDate()  ) + ' 23:59';
            }

            if(!$th.hasClass("week")){
                fd = d.getFullYear() + '-' + ((d.getMonth()<10)?  '0'+(d.getMonth()+1) : d.getMonth()+1  ) + '-' + ((d.getDate()<10)?  '0'+d.getDate() : d.getDate()  ) + ' 00:00';
                td = d.getFullYear() + '-' + ((d.getMonth()<10)?  '0'+(d.getMonth()+1) : d.getMonth()+1  ) + '-' + ((d.getDate()<10)?  '0'+d.getDate() : d.getDate()  ) + ' 23:59';
            }

            $('#route-from-date').val(fd).datetimepicker('update', fd);
            $('#route-to-date').val(td).datetimepicker('update', td);
            $('.datetimepicker').hide();
        });
$(“#从日期开始路由”).datetimepicker({
自动关闭:是的,
语言:“pl”
});
$(“#路由到日期”).datetimepicker({
自动关闭:是的,
语言:“pl”,
//今天:好的
});
$('.datetimepicker-tfoot').append('Dzisajwczorajtydzień');
$('.datetimepicker tfoot th')。在('click',function()上{
var$th=$(本);
var d=新日期();
var-fd,td;
如果($th.HASSCLASS('THE')){
d、 setDate(d.getDate()-1);
}
else if($th.HASSCLASS('week')){
d、 setDate(d.getDate()-7);

fd=d.getFullYear()+'-'+((d.getMonth()您可以执行以下操作:

$('#route-from-date').datetimepicker({
    autoclose: true,
    language: 'pl',
    showTodayButton: true
 });
 $('#route-to-date').datetimepicker({
    autoclose: true,
    language: 'pl',
    showTodayButton: true
 });
文件