i am using the lib https://jqueryui.com/datepicker/
I would like found the proprierty that send the value selected to Backend with american format.
Exemple:
JS
<script src="https://code.jquery.com/ui/1.14.0/jquery-ui.js"></script>
<script>
$( function() {
$( "#datepicker" ).datepicker();
$.datepicker.regional['pt-BR'] = {
closeText: 'Fechar',
prevText: 'Anterior',
nextText: 'Próximo',
currentText: 'Nyní',
monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto','Setembro', 'Outubro', 'Novembro', 'Dezembro'],
monthNamesShort: ['led', 'úno', 'bře', 'dub', 'kvě', 'čer', 'čvc', 'srp', 'zář', 'říj', 'lis', 'pro'],
dayNames: ['Domingo','Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'],
dayNamesShort: ['dom', 'seg', 'ter', 'qua', 'qui', 'sex', 'sab'],
dayNamesMin: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab'],
weekHeader: 'Týd',
dateFormat: 'dd/mm/yy',
firstDay: 7,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''
};
$.datepicker.setDefaults($.datepicker.regional['pt-BR']);
} );
</script>
HTML
Date: <input type="text" id="datepicker">
Alternanty, i am using the hack at onSelect function:
...
dateFormat: 'dd/mm/yy',
onSelect: function(dateText) {
// Converter a data para o formato que o backend espera
var dateObject = $(this).datepicker('getDate');
var backendFormat = $.datepicker.formatDate('yy-mm-dd', dateObject);
$("#datepickerHidden").val(backendFormat);
},
....
it force the creation of field input hidden
<input type="hidden" id="datepickerHidden">
Shall be that exists a propriety the solve it problem?
like:
...
dateFormat: 'dd/mm/yy',
dateToBackendFormat: 'yy-mm-dd',
...
Without the creation of hidden field in form and a function?
Of the way sugery, its not works to me. Cause it is necessary the creation of hidden field in form as already tell. But very well
You need to sign in to view this answers