Last active
December 17, 2015 02:29
-
-
Save macloo/41bb647efebe9f88bfa2 to your computer and use it in GitHub Desktop.
JavaScript for date string
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
// produce a data string in this format: 2015-12-17 01:31:39 | |
function getDate() { | |
var date = new Date(); | |
timestamp = date.getUTCFullYear() + '-' + | |
('00' + (date.getUTCMonth() + 1)).slice(-2) + '-' + | |
('00' + date.getUTCDate()).slice(-2) + ' ' + | |
('00' + date.getUTCHours()).slice(-2) + ':' + | |
('00' + date.getUTCMinutes()).slice(-2) + ':' + | |
('00' + date.getUTCSeconds()).slice(-2); | |
return timestamp; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment