0

Used ng prime datepicker in application.

Getting date in Fri May 14 2021 00:00:00 GMT+0530 (India Standard Time) format as response from api.

Then converting Fri May 14 2021 00:00:00 GMT+0530 (India Standard Time) this response with new Date().

Then binding the response to ng prime datepiker.

Working fine in chrome. In firefox it is showing "Invalid date".

Shanik
  • 25
  • 5
  • See [*Why does Date.parse give incorrect results?*](https://stackoverflow.com/questions/2587345/why-does-date-parse-give-incorrect-results) – RobG May 18 '21 at 20:12

1 Answers1

1

See the documentation for the Date constructor:

A string value representing a date, specified in a format recognized by the Date.parse() method. (These formats are IETF-compliant RFC 2822 timestamps, and also strings in a version of ISO8601.)

Since you aren't passing one of those formats, you are dependent on implementations having non-standard support for your format.

Chrome does. Firefox doesn't.

Use a date parsing library that lets you specify the format (such as date-fns/parse) or change the API so it outputs dates in the standard format.

Quentin
  • 857,932
  • 118
  • 1,152
  • 1,264