16 lines
388 B
JavaScript
16 lines
388 B
JavaScript
"use strict";
|
|
|
|
function twoDigit(number) {
|
|
return ("0" + number).slice(-2);
|
|
}
|
|
|
|
function timestamp(date) {
|
|
date = date || new Date();
|
|
return [ date.getFullYear(), twoDigit(date.getMonth() + 1), twoDigit(date.getDate()) ].join("-") +
|
|
" " +
|
|
[ twoDigit(date.getHours()), twoDigit(date.getMinutes()), twoDigit(date.getSeconds()) ].join(":");
|
|
}
|
|
|
|
module.exports = {
|
|
timestamp
|
|
}; |