简体   繁体   中英

datepicker jquery ui change date format to text

For picking the dates in a form I am using the JQuery UI datepicker. I know the option for setting another dateFormat like so $( ".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? I have looked into the dateFormat option but I can't get it right.. Thanks in advance

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)
  • MM - month name long
  • yy - year (four digit)

Yes, you can do it with:

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

or

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

jsFiddle example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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