简体   繁体   中英

jQuery datepicker opens on the wrong date?

I have following date format 31.12.2049 which is December 31st, 2049. When I click on the icon to open the datepicker, today's date is selected. This is using Norwegian Bokmal (nb-NO) and I noticed the date is formatted in the text, but when I open the calendar, I don't see any norwegian translations.

The date shown in the input is 31.12.2049 , so I except the ShortDateFormat to be dd.mm.yyyy , but this does not work when I do:

$(input).datepicker({ dateFormat: 'dd.mm.yyyy'});

I have to do this instead:

$(input).datepicker({ dateFormat: 'dd.mm.yy'});

The problem is that when I inspect the CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern property, it shows the format as dd.mm.yyyy

Did you set dateFormat ?

Like this:

$( ".selector" ).datepicker({
  dateFormat: "dd.mm.yy"
});

Default date format is mm/dd/yy

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