You can use the Date.parse()
method to parse a string into a Date object, but it only supports a limited number of date formats. In your case, you need to first convert the string to a supported format before parsing it.
Here's an example of how to do it using the split()
method to extract the day, month, and year components from the string, and then creating a new date object using the Date()
constructor:
index.tsx229 chars7 lines
Now date
contains a valid Date object representing the 13th of November 2022.
gistlibby LogSnag