how can I convert a date string
'13.04.2015'
into JavaScript Date object in a performant way?
how can I convert a date string
'13.04.2015'
into JavaScript Date object in a performant way?
Try this parser:
var dateString = '13.04.2015';
var myDate = new Date(dateString.split('.').reverse());
Check the demo.
Try this code:
var str = '13.04.2015',
dateParts = str.split('.'),
year = dateParts[2],
month = dateParts[1],
day = dateParts[0],
yourDate = new Date([year, month, day]);
Also if need to work a lot with dates, I would recomend you MomentJs Library
Code with it will look like:
moment('13.04.2015', 'DD.MM.YYYY')