简体   繁体   English

datepicker jquery ui将日期格式更改为文本

[英]datepicker jquery ui change date format to text

For picking the dates in a form I am using the JQuery UI datepicker. 为了选择表单中的日期,我使用了JQuery UI datepicker。 I know the option for setting another dateFormat like so $( ".selector" ).datepicker({dateFormat: "dd-mm-yy"}); 我知道设置另一个dateFormat的选项,例如$( ".selector" ).datepicker({dateFormat: "dd-mm-yy"}); . Is it possible to change this to text, so if I pick the second of March (this will get me 02-03-2017 with the option above) it will give me 2 March 2017? 是否可以将其更改为文本,所以如果我选择三月的第二天(使用上述选项,这将使我获得02-03-2017),它将给我2017年3月2日? I have looked into the dateFormat option but I can't get it right.. Thanks in advance 我已经研究了dateFormat选项,但我做对了。

The list of formatting options is here . 格式选项列表在这里 For your desired format, it should be: 对于所需的格式,应为:

$(".selector").datepicker({
    dateFormat: "d MM yy"
});
  • d - day of month (no leading zero) d每月的某天(前导零)
  • MM - month name long MM月名长
  • yy - year (four digit) yy年(四位数)

Yes, you can do it with: 是的,您可以执行以下操作:

$("#datepicker").datepicker().datepicker("option", "dateFormat", "d MM yy");

or 要么

$("#datepicker").datepicker({ "dateFormat": "d MM yy" });

jsFiddle example jsFiddle示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM