Skip to content

Instantly share code, notes, and snippets.

@objectfoo
Last active August 31, 2017 03:44
Show Gist options
  • Select an option

  • Save objectfoo/afd460ab0b8402638fa9 to your computer and use it in GitHub Desktop.

Select an option

Save objectfoo/afd460ab0b8402638fa9 to your computer and use it in GitHub Desktop.
function pad(n) {
return n < 10 ? '0' + n.toString(10) : n.toString(10);
}
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
'Oct', 'Nov', 'Dec'];
// 26 Feb 16:19:34
function timestamp() {
var d = new Date();
var time = [pad(d.getHours()),
pad(d.getMinutes()),
pad(d.getSeconds())].join(':');
return [d.getDate(), months[d.getMonth()], time].join(' ');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment