Created
June 26, 2012 19:50
-
-
Save JamesEggers1/2998424 to your computer and use it in GitHub Desktop.
A simple timestamp module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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