In below section you will find a way to convert string date into JSON date format.
I was looking for a way so that I can convert a date in string format into JSON date format. Below code can help you achieving this.
Copy below code snippet to your js file. It will definitely work for you. In below code pass input parameter in "dd-mm-yyyy" format. If your date value is in another format, you will need to do little modification in below code snippet.
//input date is in dd-mm-yyyy format
function convertToJSONDate(inputDate){
var dateArr = inputDate.split("-");
//method Date(yyyy,mm,dd)
var dt = new Date(dateArr[2],dateArr[1],dateArr[0]);
var newDate = new Date(Date.UTC(dt.getFullYear(), dt.getMonth(), dt.getDate(), dt.getHours(), dt.getMinutes(), dt.getSeconds(), dt.getMilliseconds()));
return '/Date(' + newDate.getTime() + ')/';
};
var date = convertToJSONDate("25-12-2017");
console.log("Date in JSON format is:"+ date);
Output: /Date(1516838400000)/
Hope it can help you...