I have a date in this format: '04-Aug-15'.
I want to be able to get a Date object in JS, I'm trying this:
var date = new Date(Date.parse('04-Aug-15', "MM/dd/yyyy"));
But I'm getting invalid date error message.
Any idea how can I fix this?
I have a date in this format: '04-Aug-15'.
I want to be able to get a Date object in JS, I'm trying this:
var date = new Date(Date.parse('04-Aug-15', "MM/dd/yyyy"));
But I'm getting invalid date error message.
Any idea how can I fix this?
Just pass new Date
the date string, and it'll turn it into a date.
var stringDate='04-Aug-15';
var date=new Date(stringDate);
console.log(date);
Try this to parse your date.
var date = new Date(Date.parse("04-Dec-15"));
You can then print your date by the following function.
window.alert( (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear());