Created
June 5, 2020 18:29
-
-
Save gokusenz/5181c7a79113ede8ebc48006a9061ccc to your computer and use it in GitHub Desktop.
JS Timestamp
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
var now = new Date(); | |
var nowUTC = now.getTime() + now.getTimezoneOffset() * 60 * 1000; | |
var utc_timestamp = Date.UTC(now.getFullYear(), now.getMonth(), now.getDate(), | |
now.getHours(), now.getMinutes(), now.getSeconds(), now.getMilliseconds()); | |
document.write("Correct UTC timestamp " + now.getTime()); | |
document.write("<br/>"); | |
document.write("Incorect UTC timestamp " + utc_timestamp); | |
document.write("<br/>"); | |
document.write("Incorect UTC timestamp " + nowUTC); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment