2๐
โ
I have just tried some line of codes. Do you want like this?
var data = [{value: 4111.47, text: "/Date(1540159200000)/"} ,{value: 5122.85, text: "/Date(1540245600000)/"} ,{value: 3906.24, text: "/Date(1540332000000)/"} ,{value: 3749.79, text: "/Date(1540418400000)/"} , {value: 6349.68, text: "/Date(1540504800000)/"}];
function ToJavaScriptDate(value) {
var pattern = /Date\(([^)]+)\)/;
var results = pattern.exec(value);
var dt = new Date(parseFloat(results[1]));
return (dt.getMonth() + 1) + "/" + dt.getDate() + "/" + dt.getFullYear();
}
data.map(c=>ToJavaScriptDate(c.text))
1๐
You can use this function
function ToJavaScriptDate(value) {
var pattern = /Date\(([^)]+)\)/;
var results = pattern.exec(value);
var dt = new Date(parseFloat(results[1]));
return (dt.getMonth() + 1) + "/" + dt.getDate() + "/" + dt.getFullYear();
}
ToJavaScriptDate("/Date(154564434687)/")
"11/25/1974"
1๐
You also can use momentjs library.
var yourdate = "/Date(154564434687)/";
moment(Number(yourdate.match(/\d+/)[0])).format('MM/DD/YYYY')
"11/25/1974"
Source:stackexchange.com