JQuery UI Datepicker parseDate’位置6处缺少数字’
我需要解析像’070126’到’2007年1月26日’这样的日期。 我以为我可以使用datepicker,但它给了我一个错误……
$.datepicker.parseDate('ymmdd', '070126') #=> Missing number at position 6
我开始认为这可能是一个错误……
$.datepicker.parseDate('y-mm-dd', '07-01-26') #=> Fri Jan 26 2007 00:00:00 GMT+0100 (CET)
任何建议?
谢谢..
你确定它不起作用吗? 我的代码没问题: http : //jsfiddle.net/ND2Qg/
最后我只是预处理了日期。 add_scores()函数只在每两个字符后添加’ – ‘。
$.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, '-'); }