Skip to content

Instantly share code, notes, and snippets.

@JamesEggers1
Created June 26, 2012 19:50
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 JamesEggers1/2998424 to your computer and use it in GitHub Desktop.
Save JamesEggers1/2998424 to your computer and use it in GitHub Desktop.
A simple timestamp module
module.exports = function(){
var date = new Date()
, year = date.getFullYear()
, month = date.getMonth() + 1
, day = date.getDate()
, hours = date.getHours()
, minutes = date.getMinutes()
, seconds = date.getSeconds();
if (month < 10) { month = "0" + month; }
if (day < 10) { day = "0" + day; }
if (hours < 10) { hours = "0" + hours; }
if (minutes < 10) { minutes = "0" + minutes; }
if (seconds < 10) { seconds = "0" + seconds; }
return "" + year + month + day + hours + minutes + seconds;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment