JQuery UI Datepicker parseDate 'Missing position number 6'

I need to analyze dates like "070126" - "January 26, 2007." I thought I could use datepicker, but that gives me an error ...

$.datepicker.parseDate('ymmdd', '070126') #=> Missing number at position 6 

I'm starting to think that this might be a mistake ...

 $.datepicker.parseDate('y-mm-dd', '07-01-26') #=> Fri Jan 26 2007 00:00:00 GMT+0100 (CET) 

Any tips?

Thanks..

+4
source share
2 answers

Finally, I just pre-processed the date. The add_scores () function simply adds a '-' after each two characters.

 $.datepicker.parseDate('ymmdd', add_scores('070126')); add_scores('070126'); //=> '07-01-26' function normalize_date(date){ var normalized_date = []; $.each("ymd", function(index, format_option){ normalized_date.push(date[index*2] + date[(index*2)+1]); }); return normalized_date.toString().replace(/,/g, '-'); } 
+1
source

Are you sure it does not work? I have no problem with your code: http://jsfiddle.net/ND2Qg/

+1
source

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


All Articles