To fix the "invalid date" issue in the code, we need to change the format of the date string that is passed to the Date
constructor.
One way to do this is by using a standard date format, such as 'YYYY-MM-DD', which the Date
constructor can parse:
index.tsx56 chars3 lines
This will output the date object for the specified date of November 13, 2022.
Alternatively, if you want to keep the original date format '13.11.2022', you can parse it manually and construct a new Date
object from the parsed values:
index.tsx194 chars4 lines
This will also output the date object for the specified date of November 13, 2022.
gistlibby LogSnag