Convert timezone offset number of hours to timezone offset in (military?) hours
by laucheukhim
JavaScript
function convertOffset(gmt_offset) {
var time = gmt_offset.toString().split(".");
var hour = parseInt(time[0]);
var negative = hour < 0 ? true : false;
hour = Math.abs(hour) < 10 ? "0" + Math.abs(hour) : Math.abs(hour);
hour = negative ? "-" + hour : hour;
return time[1] ? hour+(time[1]*6).toString() : hour + "00";
}
document.write(convertOffset(-3.5));