Skip to content

Instantly share code, notes, and snippets.

@alechko
Created February 4, 2018 08:01
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 alechko/ec2f538267465a7c906665b6c3a8b981 to your computer and use it in GitHub Desktop.
Save alechko/ec2f538267465a7c906665b6c3a8b981 to your computer and use it in GitHub Desktop.
JS Timestamp for console log
var now = new Date();
var h = now.getHours();
h = h > 9 ? h : '0'+h;
var m = now.getMinutes();
m = m > 9 ? m : '0'+m;
var s = now.getSeconds();
s = s > 9 ? s : '0'+s;
var ms = now.getMilliseconds();
n = '['+h+':'+m+':'+s+'.'+ms+'] '+n;
console.log(n,item);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment