Change language for bootstrap DateTimePicker

前端 未结 11 1651
长发绾君心
长发绾君心 2020-12-03 04:15

I use bootstrap-datetimepicker.js Copyright 2012 by Stefan Petre

http://www.malot.fr/bootstrap-datetimepicker/index.php

I import the js and anot

11条回答
  •  误落风尘
    2020-12-03 05:06

    1.First add this js file to your HTML.

    
    

    obviously after moment.min.js.

    content of bootstrap-datepicker.nl.min.js will be

    ;(function($){
        $.fn.datepicker.dates['nl'] = {
            days: ["Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag"],
            daysShort: ["Zon", "Man", "Din", "Woe", "Don", "Vri", "Zat", "Zon"],
            daysMin: ["Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za", "Zo"],
            months: ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"],
            monthsShort: ["Jan", "Feb", "Mrt", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"],
            today: "Vandaag",
            suffix: [],
            meridiem: []
        };
        $.fn.datetimepicker.dates['nl'] = {
            days: ["Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag"],
            daysShort: ["Zon", "Man", "Din", "Woe", "Don", "Vri", "Zat", "Zon"],
            daysMin: ["Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za", "Zo"],
            months: ["Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December"],
            monthsShort: ["Jan", "Feb", "Mrt", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"],
            today: "Vandaag",
            suffix: [],
            meridiem: []
        };
    }(jQuery));
    

    2.set this line in the ready function of your js file.

    $(document).ready(function () {
        $.fn.datetimepicker.defaults.language = 'nl';
    }
    

    3.initialize your datetimepicker in this way

    $(this).datetimepicker({
                            format: "yyyy-mm-dd hh:ii",
                            autoclose: true,
                            weekStart: 1,
                            locale: 'nl',
                            language: 'nl'
                        });
    

    following this steps i was able to convert my english datepicker and datetimepicker to dutch successfully.

提交回复
热议问题