How to Convert JSON Date Format to Javascript Date
March 18, 2015 , in Javascript | Reading time : 1 min.
When getting data from a REST service, it is common to serialize the data as JSON string. Parsing the data returned into a javascript object is easy with a simple eval. But when the data returned includes a date, then the JSON date format usually looks like
|
|
To convert this date to the standard date format for display to the frontend, we first need to extract the date part as below:
|
|
To further convert this into the standard date formatting, you can simply use the Javascript’s toLocaleDateString() method [if the date is only to display as a string to the frontend]
|
|