Created
April 24, 2015 08:01
-
-
Save tsq/787c032935a2d974e9fa to your computer and use it in GitHub Desktop.
year + month + date + hour + miniute
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 getTime() { | |
var date = new Date(); | |
var year = date.getFullYear(); | |
var month = (date.getMonth() + 1); | |
month = (month < 9) ? '0' + month : month; | |
var day = date.getDate(); | |
day = (day < 9) ? '0' + day : day; | |
var hour = date.getHours(); | |
hour = (hour < 9) ? '0' + hour : hour; | |
var minite = date.getMinutes(); | |
minite = (minite < 9) ? '0' + minite : minite; | |
var time = year + '' + month + day + hour + minite; | |
return time; | |
} | |
console.log(getTime()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment