In my AngularJs application, I am getting the date in string format which I need to convert to datetime and show in a datepicker. It’s working in Chrome but in Firefox converting string to datetime is showing “Invalid Date” error. I have used below code
Worth pointing out MDN discourages using date strings for construction at all, instead pointing to either passing the timestamp as integer, or the integer values of year, monthIndex (Month - 1), and then optionally the day, hours, minutes, seconds, and milliseconds parameters.
new Date(2021,1,11,19,11); new Date(1613088660000); <- Date Thu Feb 11 2021 19:11:00 GMT-0500 (Eastern Standard Time)
(the timestamp may obviously be different, depending on what time zone you are in.)