Skip to content

Instantly share code, notes, and snippets.

@kanakiyajay
Created August 22, 2014 09:23
Show Gist options
  • Save kanakiyajay/342f44d75ef6d86933cb to your computer and use it in GitHub Desktop.
Save kanakiyajay/342f44d75ef6d86933cb to your computer and use it in GitHub Desktop.
Get pretty timestamp in javascript
function getTimeStamp() {
var now = new Date();
return ((now.getMonth() + 1) + '/' +
(now.getDate()) + '/' +
now.getFullYear() + " " +
now.getHours() + ':' +
((now.getMinutes() < 10)
? ("0" + now.getMinutes())
: (now.getMinutes())) + ':' +
((now.getSeconds() < 10)
? ("0" + now.getSeconds())
: (now.getSeconds())));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment