JSFiddle - React, Tailwind, and code Playground

by Sillvva

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/en-gb.js"></script>
<div id="output">

</div>

JavaScript

moment.locale("en");
const times = [];
times.push("<strong>Example formats:</strong>")
times.push(moment().format('LT'));   // 11:35 AM
times.push(moment().format('LTS'));  // 11:35:06 AM
times.push(moment().format('L'));    // 09/04/2019
times.push(moment().format('l'));    // 9/4/2019
times.push(moment().format('LL'));   // September 4, 2019
times.push(moment().format('ll'));   // Sep 4, 2019
times.push(moment().format('LLL'));  // September 4, 2019 11:35 AM
times.push(moment().format('lll'));  // Sep 4, 2019 11:35 AM
times.push(moment().format('LLLL')); // Wednesday, September 4, 2019 11:35 AM
times.push(moment().format('llll')); // Wed, Sep 4, 2019 11:35 AM
times.push("")
const isotime = '2019-07-05T21:32:00+0200';
times.push("<strong>Current locale format:</strong> "+moment.locale())
times.push("<strong>Converting an ISO date string to local time:</strong>")
times.push(moment.parseZone(isotime).local().format('L LT'))
times.push(moment.parseZone(isotime).local().format('LL LT'))
times.push("")
moment.locale("en-gb");
times.push("<strong>Current locale format:</strong> "+moment.locale())
times.push("<strong>Converting an ISO date string to local time:</strong>")
times.push(moment.parseZone(isotime).local().format('L LT'))
times.push(moment.parseZone(isotime).local().format('LL LT'))
document.getElementById("output").innerHTML = times.join("<br />");