Skip to content

Instantly share code, notes, and snippets.

@tsq
Created April 24, 2015 08:01
Show Gist options
  • Save tsq/787c032935a2d974e9fa to your computer and use it in GitHub Desktop.
Save tsq/787c032935a2d974e9fa to your computer and use it in GitHub Desktop.
year + month + date + hour + miniute
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