JSFiddle - React, Tailwind, and code Playground
by Sillvva
HTML
<div id="test"> </div>
CSS
body { background: white; }
JavaScript
const parseTimeZoneISO = timezone => {
const tz = Math.abs(timezone);
const hours = Math.floor(tz);
const minutes = ((tz - hours)) * 60;
const zeroPad = (n, width, z = "0") => {
n = n + "";
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
};
return zeroPad(hours, 2) + zeroPad(minutes, 2);
};
const output = parseTimeZoneISO(5);
console.log(output)
document.getElementById('test').innerHTML = output;