I'm trying to get a date with the following format using the jquery ui datepicker: d de MM de yy. Example: 8 de Enero de 2016
I've try with: dateFormat: 'd \de MM \de yy' dateFormat: 'd 'de' MM 'de' yy' but it's not working as I expected, it displays 8 8e Enero 8e 2016 instead of 8 de Enero de 2016. I have the code in the folling fiddle: http://jsfiddle.net/yewnu9jL/1/
<input type="text" id="datepicker">
$(function(){
$.datepicker.regional["es"] = {
closeText: "Cerrar",
prevText: "<Ant",
nextText: "Sig>",
currentText: "Hoy",
monthNames: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"],
monthNamesShort: ["Ene","Feb","Mar","Abr", "May","Jun","Jul","Ago","Sep", "Oct","Nov","Dic"],
dayNames: ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"],
dayNamesShort: ["Dom","Lun","Mar","Mié","Juv","Vie","Sáb"],
dayNamesMin: ["Do","Lu","Ma","Mi","Ju","Vi","Sá"],
weekHeader: "Sm",
dateFormat: "dd/mm/yy",
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ""
};
$.datepicker.setDefaults($.datepicker.regional["es"]);
$('#datepicker').datepicker({
dateFormat: 'd de MM de yy',
maxDate: 0,
onSelect: function() {
$('#form-fecha').submit();
}
}).datepicker('setDate', new Date());
});
How can I do it?
The simplest approach is to quote the text with single quotes... but to do that as simply as possible, you should use double quotes for the overall value:
dateFormat: "d 'de' MM 'de' yy"
See more on this question at Stackoverflow