JQuery UI Datepicker parseDate'6号缺失号码' [英] JQuery UI Datepicker parseDate 'Missing number at position 6'
本文介绍了JQuery UI Datepicker parseDate'6号缺失号码'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要解析070126到2007年1月26日的日期。我以为我可以使用datepicker,但它给我一个错误...
$。datepicker.parseDate('ymmdd ','070126')#=>第6位缺少号码
我开始认为这可能是一个错误...
$。datepicker.parseDate('y-mm-dd','07 -01-26')#=> 2007年1月26日星期一00:00:00 GMT + 0100(CET)
任何建议? >
谢谢..
解决方案
最后我只是预处理日期。
函数add_scores()在每两个字符之后加上 - 。
$。datepicker.parseDate ymmdd',add_scores('070126'));
add_scores('070126'); // => '07 -01-26'
函数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,' - ');
}
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..
解决方案
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, '-');
}
这篇关于JQuery UI Datepicker parseDate'6号缺失号码'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文