I have a key-value list which is displayed in a tabular format where the key is the label. Some of the values are JSON-date-strings in ISO 8601/XKCD format (e.g. 2012-04-23T18:25:43.511Z
). How can I separate them from normal strings in order to display them as a date?
Currently, I am using !isNaN(new Date(string))
which is true when the date-string is valid. This works fine because my values are non-numerical BUT this might change in the future. How can I make sure that only valid JSON-date-strings are formatted as a date?
I am not looking for regex or similar solutions.