我想用以下格式使用jquery ui datepicker獲取日期:d de MM de yy。例如:8日Enero日2016無法從dateFormat獲取文字'de'。例如:8 de Enero de 2016
我已經嘗試: DATEFORMAT: 'd \德MM \去YY' DATEFORMAT:倒是'德' MM '德' YY' 但它不工作,我預計,它會顯示8 8E Enero 8E 2016,而不是8日Enero德2016年 我在folling小提琴代碼: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());
});
我該怎麼辦呢?
「它不工作」並不告訴我們會發生什麼。你是否嘗試過'dateFormat:'d'de'MM'de'yy「'來避免撇號字符串提前終止的問題? –
它顯示「8 8e Enero 8e 2016」而不是「8 de Enero de 2016」 – igogra
哪一個?你提到了兩個建議,我已經提出了第三個建議......你也可以嘗試「d \\ d \\ MM \\ d \\ e yy''。 (但看着文檔,我期待我在第一條評論中提出的建議) –