0

I have a string that returns as "2021-12-11/2021-12-14" or "2021-12-11" in the json response, and i'd like to validate that the field is in iso 8601 format.

i'm not sure how to do this; should i be parsing it and then comparing to YYYY-MM-DD?

thanks in advance for any help i can get!

  • Does this answer your question? [Validating a ISO 8601 date using moment.js](https://stackoverflow.com/questions/22164541/validating-a-iso-8601-date-using-moment-js) – Christian Baumann Dec 19 '21 at 09:49
  • I think `moment` compares the date to the current date doesnt it? the dates can be anything, i just need it to be of the ISO format. – a_little_truck Dec 21 '21 at 06:38
  • @a_little_truck How about [these](https://stackoverflow.com/questions/52869695/check-if-a-date-string-is-in-iso-and-utc-format) answers? – Nikita Skrebets Dec 26 '21 at 15:05

0 Answers0