1

我有来自日历控件的保加利亚短日期模式字符串如何在不删除“г”的情况下创建日期对象。从中。

new Date('26.6.2015 г.')

我想比较从日历中选择的日期和今天的日期

 if (($.datepicker.formatDate('yy/mm/dd', new Date()))
     ($.datepicker.formatDate('yy/mm/dd', new Date('26.6.2015 г.'))))

           { alert('success')}
4

1 回答 1

0

this might help you .

var stringDate='26.6.2015 г.';// assuming this the format you get and used regex to match this pattern
stringDate=stringDate.substring(0, stringDate.indexOf(' '));// to remove everything after space including space
var pattern = /^(\d{1,2})\.(\d{1,2})\.(\d{4})$/;
var arrayDate = stringDate.match(pattern);
var dt = new Date(arrayDate[3], arrayDate[2] - 1, arrayDate[1]);
console.log(dt)// this is date object

于 2015-09-11T18:10:03.760 回答