While working with a .net asmx webservice, I encountered an issue with the date format being returned. The date field is in the form of:
"effective_date":"\/Date(978411600000)\/"
After researching on Stack Overflow here: How do I format a Microsoft JSON date?, it became clear that converting the date to ISO 8601 format would allow JavaScript to interpret it correctly.
Currently, when using new Date(d.effective_date)
in JavaScript, I receive an error message stating Invalid Date
. It was suggested in the SO question that formatting the date in ISO standard instead of \/Date(978411600000)\/
should resolve this issue.
Hence, my query is - how can I modify the webservice to return the date in ISO 8601 format?
Note: Although I am aware of using
var date = new Date(parseInt(d.effective_date.substr(6)));
as mentioned in one of the answers, the preferable approach according to a comment is for the incoming date values to be formatted in ISO-8601. Therefore, I'm seeking guidance on how to ensure the date from the web service comes in this ISO standard format.