After scouring SO and coming up empty, I'm forging ahead with my question:
I've got a date string that's dependent on locale, along with the locale info itself.
For example, dateStr = '06/07/2021'
and locale='en-GB'
.
How can I convert this into a JS Date object? The Date constructor seems to only parse it in en-US format by default (MM-DD-YYYY).
This means that the above dateStr would be interpreted as 7th June 2021
instead of the correct 6 July 2021
when using the Date constructor.
UPDATE:
I tried using d2l-intl, but strangely, it doesn't work.
var parser = new d2lIntl.DateTimeParse('en-GB');
var date = parser.parseDate('23/05/2021');
console.log(
date.getMonth(),
date.getDate()
);
Unfortunately, it still requires the date string to be in en-US format.