Created
March 30, 2018 04:56
-
-
Save herbowicz/dca6bd071d507d8ea0a11e048cd9a1e3 to your computer and use it in GitHub Desktop.
time utility function
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 time() { | |
const now = new Date(), | |
h = now.getHours(), | |
m = now.getMinutes(), | |
s = now.getSeconds() | |
return `${h === 0 ? 12 : h > 12 ? h - 12 : h}:${(m <= 9 && '0') + m}:${(s <= 9 && '0') + s} ${h >= 12 ? 'PM' : 'AM'}` | |
} | |
time() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment