Date formatting in jquery datepicker

that's all ... I was wondering how I can format the date in the date "d de MM de yy" instead of "dd / MM / yy".

(suppose the date is 01/21/2011 (in Spanish) .. like this: $ ("# Element"). DatePicker ({dateFormat: 'd de MM de yy'});

He will output: 21 21e Enero 21e yy

The question is, is there an escape character so that I can format the date? Thank you, sorry for my English, hope you guys understand

+4
source share
3 answers

You can avoid any text characters:

$("#element").datepicker({ dateFormat:'d \\d\\e MM \\d\\e yy' }); 

You can also avoid plain text by using single quotes:

 $("#element").datepicker({ dateFormat:"d 'de' MM 'de' yy" }); 
+5
source

You can define a datepicker at startup, and then just use the class to attach it later. I defined datepicker as follows:

 $(".date-pick").datepicker($.extend({}, $.datepicker.regional["no"], {showStatus: true, defaultDate: +1, minDate: 1, maxDate: 365, dateFormat: "dd.mm.yy", showOn: "both", buttonImage: "../images/shop/calendar.png", buttonImageOnly: true})); 

Must be explained in the parameters / documentation.

+1
source

Try this for date and year format until current year

 $('#element').datepicker({ dateFormat: "dd M yy", changeMonth: true, changeYear: true, yearRange: "1920:+nn", maxDate: 0 }); 
0
source

Source: https://habr.com/ru/post/1336471/


All Articles