Question

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..

Was it helpful?

Solution 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, '-');
    }

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top