Created
October 14, 2018 15:41
-
-
Save DavidEredics/c10fff5e6a4f6fc8867e042533aee1c6 to your computer and use it in GitHub Desktop.
JavaScript UTC DateTime function
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
function DateTime(){ | |
var date = new Date(); | |
var year = date.getUTCFullYear(); | |
var month = date.getUTCMonth() + 1; | |
month = (month < 10 ? "0" : "") + month; | |
var day = date.getUTCDate(); | |
day = (day < 10 ? "0" : "") + day; | |
var hour = date.getUTCHours(); | |
hour = (hour < 10 ? "0" : "") + hour; | |
var minutes = date.getUTCMinutes(); | |
minutes = (minutes < 10 ? "0" : "") + minutes; | |
var seconds = date.getUTCSeconds(); | |
seconds = (seconds < 10 ? "0" : "") + seconds; | |
return year + "/" + month + "/" + day + "-" + hour + ":" + minutes + ":" + seconds; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment