JSFiddle - React, Tailwind, and code Playground
by austinfrance
HTML
<div>ISO DATE: 2020-10-08T20:00:00+01:00</div>
<input id="locale" value="en-GB" onchange="recalc()">
<div id="output"></div>
<div id="offset"></div>
<div id="valueOf"></div>
<div id="isodate"></div>
<div id="default"></div>
JavaScript
function recalc() {
const date = new Date(Date.parse("2020-10-08T20:00:00+01:00"));
const locale = document.getElementById("locale").value;
document.getElementById("output").innerText = `${date.toLocaleString(locale)}`;
document.getElementById("offset").innerText = `${date.getTimezoneOffset()}`;
document.getElementById("valueOf").innerText = `${date.valueOf()}`;
document.getElementById("isodate").innerText = `${date.toISOString()}`;
document.getElementById("default").innerText = `${date.toLocaleString()}`;
}
recalc();