I have several dates in this text format:
var date = "March 12th 2015, 8:37:29 pm";
I want to get a date object but I am getting invalid date when creating the date object.
I tried just doing:
var date_o = new Date(date);
No success. Also tried:
var at = Date.parse(date.replace(/[ap]m$/i, ''));
if(date.match(/pm$/i) >= 0) {
at += 12 * 60 * 60 * 1000;
}
var date_o = new Date(at);
No success. What would be the correct way?
I think I should tell the date object that will get a string with "format('MMMM Do YYYY, h:mm:ss a')"
. Is this possible?