DateTime Picker in Portuguese

1

I've added the DateTimePicker component to my project.

ButthesameisallinEnglish,Iaddedtheoptionofpt-BRinthefunctionthatcreatesitinthefield,andeventhenitcontinuesinEnglish.HowdoIgetthemonths/daysoftheweektobept-BR?

functionatualizarCalendariosHora(){$(".calendarioHora").mask("99/99/9999 99:99");
    $(".calendarioHora").datetimepicker("destroy");

    $(".calendarioHora:not([readonly='readonly']):not([readonly='true'])").datetimepicker({
        format: 'd/m/Y H:i',
        lang: 'pt-BR',
        mask: '99/99/9999 99:99',
        onClose: function () {
            try {
                $(this).valid();
            }
            catch (e) {
            }
        }
    });
}
    
asked by anonymous 24.03.2016 / 13:25

3 answers

3

I was able to solve my problem with: $.datetimepicker.setLocale('pt-BR'); after setting the DateTimePicker.

function atualizarCalendariosHora() {
    $(".calendarioHora:not([readonly='readonly']):not([readonly='true'])").datetimepicker({
        format: 'd/m/Y H:i',
        mask: '99/99/9999 99:99',
        onClose: function () {
            try {
                $(this).valid();
            }
            catch (e) {
            }
        }
    });

    $.datetimepicker.setLocale('pt-BR');
}
    
24.03.2016 / 14:09
3

You can choose what you want to enter information for example. Home DAYNAMES = Name of days.
You put the names inside an array and it will appear on your calendar! The following code demonstrates some attributes that you can change.

$(".data").datepicker({
    dateFormat: 'dd/mm/yy',
    dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado'],
    dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
    dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'],
    monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
    monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
    nextText: 'Próximo',
    prevText: 'Anterior'
});
<link type="text/css" href="http://www.botecodigital.info/exemplos/datapicker/css/custom-theme/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
<script type="text/javascript" src="http://www.botecodigital.info/exemplos/datapicker/js/jquery-1.7.2.min.js"></script><scripttype="text/javascript" src="http://www.botecodigital.info/exemplos/datapicker/js/jquery-ui-1.8.20.custom.min.js"></script><inputtype="text" class="data hasDatepicker" id="dp1458823238871">

You can check out an example on this site:
link
Inspect the source code and see how simple it is!

Try to leave your script like this:

function atualizarCalendariosHora() {
    $(".calendarioHora").mask("99/99/9999 99:99");
    $(".calendarioHora").datetimepicker("destroy");

    $(".calendarioHora:not([readonly='readonly']):not([readonly='true'])").datetimepicker({
        format: 'd/m/Y H:i',
        lang: 'pt-BR',
       dateFormat: 'dd/mm/yy',
    dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado'],
    dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
    dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'],
    monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
    monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
    nextText: 'Próximo',
    prevText: 'Anterior',
        mask: '99/99/9999 99:99',
        onClose: function () {
            try {
                $(this).valid();
            }
            catch (e) {
            }
        }
    });
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    
24.03.2016 / 13:39
1

Try to create the DatePicker like this:

$(".calendarioHora").datepicker({ dateFormat: 'dd/mm/yy', dayNames: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado', 'Domingo'], dayNamesMin: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S', 'D'], dayNamesShort: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb', 'Dom'], monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'], monthNamesShort: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'] });

    
24.03.2016 / 13:31