JQuery UI Datepicker parseDate 'Missing number at position 6'

别说谁变了你拦得住时间么 提交于 2019-12-22 08:34:30

问题


I need to parse dates like '070126' to '26 Jan 2007'. I thought I could use the datepicker, but it gives me the an error...

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

I am starting to think that this could be a bug...

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

Any advice?

Thanks..


回答1:


Are you sure it is not working? I have no problems with your code: http://jsfiddle.net/ND2Qg/




回答2:


Finally i just preprocessed the date. The function add_scores() just adds '-' 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, '-');
    }


来源:https://stackoverflow.com/questions/5390521/jquery-ui-datepicker-parsedate-missing-number-at-position-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!