Skip to content

Instantly share code, notes, and snippets.

@trastle
Created April 19, 2013 09:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trastle/5419236 to your computer and use it in GitHub Desktop.
Save trastle/5419236 to your computer and use it in GitHub Desktop.
Timestamp in JS (yuk)
function timeStamp() {
var d = new Date();
var hour = ('0' + d.getHours()).slice(-2);
var min = ('0' + d.getMinutes()).slice(-2);
var sec = ('0' + d.getSeconds()).slice(-2);
var mil = ('000' + d.getMilliseconds()).slice(-3);
return hour + ":" + min + ":" + sec + "(" + mil + ")";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment