Last active
June 8, 2016 04:32
-
-
Save k-yle/75990722a43b3f07954f68ec149c1046 to your computer and use it in GitHub Desktop.
🕒 get the true time in any timezone
This file contains hidden or 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 Time = UTCoffset => { | |
var d = new Date(), | |
utc = d.getTime() + (d.getTimezoneOffset() * 60000), | |
n = new Date(utc + (3600000 * UTCoffset)), | |
f = n.toLocaleString().toString().split(', '), | |
e = f[0].split('/'); | |
if (Number(e[0]) < 10) | |
e[0] = 0 + e[0]; | |
if (Number(e[1]) < 10) | |
e[1] = 0 + e[1]; | |
return [`${e[1]}-${e[0]}-${e[2]}`, f[1]]; //DST - https://msdn.microsoft.com/en-us/library/jj863688(v=vs.85).aspx | |
} | |
if (typeof module != 'undefined') | |
module.exports = Time; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: