Created
April 14, 2020 13:46
-
-
Save lukasbach/fff160c54a75baad5868f82843dc0090 to your computer and use it in GitHub Desktop.
Format Timezone Offset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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