I have a string in JavaScript 2015-07-22 00:00:00.0
. I need this to be converted to mm/dd/yy
format
I tried parsing with var d = new Date(from_date);
, which works in Chrome,but not in IE or Firefox
Then I tried with regex pattern replace, but it still works only in Chrome but not in IE or Firefox
var st = '2015-07-22 00:00:00.0'
var pattern = '\d{4})\-(\d{2})\-(\d{2})/'
var dt = new Date(st.replace(pattern, '$2-$3-$1'));
var output = dt.getMonth() + 1 + '/' + dt.getDate() + '/' + dt.getFullYear();
alert(output)
Kindly throw some light.