JSFiddle - React, Tailwind, and code Playground

by willtx

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/moment-with-locales.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.27/moment-timezone.min.js"></script>
<head>
<script type="text/javascript">
        moment.tz.add([
            'America/New_York|EST EDT|50 40|0101|1Lz50 1zb0 Op0'
        ]);
        
        function getESTDateTime(dateTicks){
        console.log('...in func');
        if (dateTicks == null || dateTicks === "")
            return "";

        if (typeof dateTicks !== "string")
            return "";

        //const startIdx = dateTicks.indexOf('(');
        //const endIdx = dateTicks.indexOf(')');
        //const ticksString = dateTicks.substring(startIdx + 1, endIdx);
        const ticksString = dateTicks;
        const ticks = Number(ticksString);
        console.log('ticks');
        console.log(ticks);
        const date = moment.utc(new Date(ticks));
       //const date = moment(ticks / 10000);
        console.log('date before');
        console.log(date.format('MMMM Do YYYY, h:mm:ss a'));
        const utcString = date.format('MMMM Do YYYY, h:mm:ss a');
        let utc = document.getElementById("utcValue");
        utc.textContent  = utcString;
        //date comes in as UTC -> EST
        const convertedDateTime = moment.utc(date.toISOString()).tz('America/New_York').format('MMMM Do YYYY, h:mm:ss a');
        console.log('date after');
        console.log(convertedDateTime);
        let est = document.getElementById("estValue")
        est.textContent  = convertedDateTime;
        //!!! this works
          const est2 = new Date(ticks).toLocaleString("en-US", {timeZone: "America/New_York"});
         console.log('est2');
        console.log(est2);
        return convertedDateTime;
	}
</script>
</head>
<body>
  <input id="ticksValue" placeholder="ticks" value="1578501251823"></input>
 ...