我想在我的WordPress网站上显示日期,如图片,其中长名称的月份缩写。
我的jquery看起来像这样:
jQuery(document).ready( function($){
var txtFromDate, txtToDate;
$("#txtFrom").datepicker({
numberOfMonths: 1,
onSelect: function(selected) {
txtFromDate = selected;
var dt = new Date(selected);
dt.setDate(dt.getDate() + 1);
$("#txtTo").datepicker("option", "minDate", dt);
}
});
$("#txtTo").datepicker({
numberOfMonths: 1,
onSelect: function(selected) {
txtToDate = selected;
var dt = new Date(selected);
dt.setDate(dt.getDate() - 1);
$("#txtFrom").datepicker("option", "maxDate", dt);
}
});
$('a#atributo').click(function() {
// var link = day_1+month_1+year;
var monthNames = [
"Jan", "Feb", "Mar",
"Apr", "May", "Jun", "Jul",
"Aug", "Sep", "Oct",
"Nov", "Dec"
];
var date1 = $("#txtFrom").datepicker('getDate'),
day_1 = date1.getDate(),
month_1 = date1.getMonth() + 1,
year_1 = date1.getFullYear();
var date2 = $("#txtTo").datepicker('getDate'),
day_2 = date2.getDate(),
month_2 = date2.getMonth() + 1,
year_2 = date2.getFullYear();
var where = $('#selection :selected').text();
var people = $('#search-pax :selected').val();
$(this).attr("href", "http://www.lekkeslaap.co.za/akkommodasie-in/"+where+"?q="+where+"&start="+day_1+"+"+monthNames[month_1]+"+"+year_1+'&end='+day_2+'+'+monthNames[month_2]+'+'+year_2+'&pax='+people);
});
});
现在,当我查看网站时,它看起来像这样:
如何更改日期格式?
我在api文档中找到this,但我正在努力实现
希望你能提供帮助并here my full pen for it
答案 0 :(得分:1)
在逗号后面有" numberOfMonths:1,"加上这个:
dateFormat: "d/M/yy"
欢迎您通过破折号或任何内容更改斜杠
答案 1 :(得分:0)
您需要在datepicker选项中添加dateFormat选项:
dateFormat: "d M yy"