Skip to content

Instantly share code, notes, and snippets.

@samuell
Created September 14, 2010 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuell/579531 to your computer and use it in GitHub Desktop.
Save samuell/579531 to your computer and use it in GitHub Desktop.
function getDateTimeString() {
var d = new Date();
var now = d.getFullYear() + "-" +
pad( d.getMonth(), 2 ) + "-" +
pad( d.getDate(), 2 ) + "." +
pad( d.getHours(), 2 ) + "." +
pad( d.getMinutes(), 2 ) + "." +
pad( d.getSeconds(), 2 );
return now;
}
function pad(number, length) {
var str = '' + number;
while (str.length < length) {
str = '0' + str;
}
return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment