Last active
January 26, 2022 18:47
-
-
Save CuzImBisonratte/435ed58f330bac365039b05cde9351d8 to your computer and use it in GitHub Desktop.
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
// Function to format the time | |
function formatTime(number) { | |
// If the number is not 2 digits, add a 0 in front | |
if (number.toString().length <= 1) { | |
// Add a 0 in front | |
number = "0" + number; | |
} | |
// return the formatted number | |
return number; | |
} |
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
// Function to format a number with dots as thousands separator | |
function formatNumber(number) { | |
// Replace the decimal point | |
var numberNew = number.toString().split(".")[0].replace(/\B(?=(\d{3})+(?!\d))/g, "."); | |
// replace english point with german comma | |
if (number.toString().split(".")[1] != undefined) { | |
numberNew = numberNew + "," + number.toString().split(".")[1]; | |
} | |
// return the formatted number | |
return numberNew; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment