Here is an example function that can parse a date or datetime with different source formats including American standards and ISO 8601 in Javascript. It makes use of regular expressions to identify and extract different parts of the date or datetime string.
index.tsx1155 chars29 lines
To use this function, simply pass in a string representing the date or datetime you want to parse, and it will return a Date object if successful or NaN if not. For example:
index.tsx329 chars4 lines
gistlibby LogSnag