Skip to content

Instantly share code, notes, and snippets.

@stefanocudini
Created March 25, 2012 13:00
Show Gist options
  • Save stefanocudini/2193525 to your computer and use it in GitHub Desktop.
Save stefanocudini/2193525 to your computer and use it in GitHub Desktop.
datetime
var d = new Date(),T={};
T.Y = d.getFullYear(),
T.M = d.getMonth()+1,
T.D = d.getDate(),
T.h = d.getHours(),
T.m = d.getMinutes(),
T.s = d.getSeconds();
for(t in T)
T[t] = T[t]>9 ? T[t] : '0'+T[t];
var time = [T.D,T.M,T.Y].join('-')+' '+[T.h,T.m,T.s].join(':');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment