Skip to content

Instantly share code, notes, and snippets.

@lukasbach
Created April 14, 2020 13:46
Show Gist options
  • Save lukasbach/fff160c54a75baad5868f82843dc0090 to your computer and use it in GitHub Desktop.
Save lukasbach/fff160c54a75baad5868f82843dc0090 to your computer and use it in GitHub Desktop.
Format Timezone Offset
const formatTimeZoneOffset = (offset: number) => {
return (
(offset >= 0 ? '+' : '-') +
('0' + Math.floor(Math.abs(offset))).slice(-2) +
':' +
('0' + Math.round((Math.abs(offset) % 1) * 60)).slice(-2)
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment