Skip to content

Instantly share code, notes, and snippets.

@JTBrinkmann
Created June 28, 2016 20:03
Show Gist options
  • Save JTBrinkmann/08329adb12ebf9d9ac0c9eae0cb64bbe to your computer and use it in GitHub Desktop.
Save JTBrinkmann/08329adb12ebf9d9ac0c9eae0cb64bbe to your computer and use it in GitHub Desktop.
aux = {
pad: function(num, digits){
return 0 <= num && num < 10
? "0" + num
: num + ""
},
getChatTimestamp: function(is24h) {
d = new Date()
h = d.getHours()
if (is24h) {
return pad(h) + ":" + pad(d.getMinutes())
} else {
return pad(h % 12 || 12) + ":" + pad(d.getMinutes()) + " " + (h < 12 ? 'am' : 'pm')
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment