jquery globalize convert bulgerian shortdate pattern date string to date object

58 views Asked by At

I have bulgarian short date pattern string from calendar control how can I create date object without removing 'г.' from it.

new Date('26.6.2015 г.')

I wanted to compare the date selected from calender with today's date

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

           { alert('success')}
1

There are 1 answers

0
J Santosh On

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