console.log(Date.parse('Wed Jul 07 04:49:10 IST 2021')); // returns NAN
console.log(Date.parse('Wed Jul 07 04:49:10 EDT 2021')); // working as expected
How to convert IST dateString (Wed Jul 07 04:49:10 IST 2021) to number.
console.log(Date.parse('Wed Jul 07 04:49:10 IST 2021')); // returns NAN
console.log(Date.parse('Wed Jul 07 04:49:10 EDT 2021')); // working as expected
How to convert IST dateString (Wed Jul 07 04:49:10 IST 2021) to number.
As mentioned in comments, spec doesn't prescribe Date.parse()
to handle the timezone abbreviations. Only a few of those are supported by major Date.parse()
implementations out-of-the-box, and EDT is one of them. The biggest issue with recognizing IST is that this abbreviation might actually mean three different things:
... so it's quite difficult to parse the source string in a deterministic way. So your best bet would be replacing IST with a numeric timezone identifier (+05:30
for India Standard Time, for example).