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

これはあなたを助けるかもしれません。

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 に答える