Created
July 20, 2017 06:25
-
-
Save MJ111/d30a5934361662dae36fd7a650126233 to your computer and use it in GitHub Desktop.
Calculate milliseconds between midnight and present time according to universal time
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 now = new Date(); | |
const utcnow = Date.UTC( | |
now.getUTCFullYear(), | |
now.getUTCMonth(), | |
now.getUTCDate(), | |
now.getUTCHours(), | |
now.getUTCMinutes(), | |
now.getUTCMilliseconds() | |
); | |
let utctmr = Date.UTC( | |
now.getUTCFullYear(), | |
now.getUTCMonth(), | |
now.getUTCDate() + 1, | |
0, | |
0, | |
0 | |
); | |
setTimeout(() => { | |
console.log('gotcha!') | |
}, utctmr - utcnow); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment