14 lines
373 B
JavaScript
14 lines
373 B
JavaScript
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
|
|
}; |