14 lines
393 B
TypeScript
14 lines
393 B
TypeScript
function twoDigit(number: number): string {
|
|
return ("0" + number).slice(-2);
|
|
}
|
|
|
|
function timestamp(date?: Date): string {
|
|
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(":");
|
|
}
|
|
|
|
export {
|
|
timestamp
|
|
}; |