Moment JS
Example of parsing and formatting a Date with Moment JS.
by Andrew Gerst
HTML
<script src="https://momentjs.com/downloads/moment.js"></script>
<script src="https://momentjs.com/downloads/moment-timezone-with-data-1970-2030.min.js"></script>
<pre id="content"></pre>
JavaScript
// Moment JS - Formatting Guide: http://momentjs.com/docs/#/parsing/string-format/
const customTimezone = ['America/Los_Angeles', 'US/Mountain', 'America/Chicago', 'America/New_York', 'Europe/London'][2];
const utcTime = '2020-01-30T01:00:00Z';
const localTime = '05/15/2019 4:00 am';
const dateFormat = 'MM/DD/YYYY h:mm a - dddd';
const body = [];
body.push('<b>Default Timezone</b>');
body.push('<br><br>');
body.push(moment(utcTime).format(dateFormat));
body.push('<br><br>');
body.push(moment(localTime).utc().format());
body.push('<br><br>');
body.push(`<b>Timezone: ${customTimezone}</b>`);
body.push('<br><br>');
body.push(moment.tz(utcTime, customTimezone).format(dateFormat));
body.push('<br><br>');
body.push(moment.tz(localTime, dateFormat, customTimezone).utc().format());
document.getElementById('content').innerHTML = body.join('');