mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-22 07:57:59 +00:00
21 lines
662 B
JavaScript
21 lines
662 B
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.formatDate = formatDate;
|
|
/** @internal */
|
|
function zeroPad(value) {
|
|
return value.toString().padStart(2, '0');
|
|
}
|
|
/**
|
|
* @name formatDate
|
|
* @description Formats a date in CCYY-MM-DD HH:MM:SS format
|
|
*/
|
|
function formatDate(date) {
|
|
const year = date.getFullYear().toString();
|
|
const month = zeroPad((date.getMonth() + 1));
|
|
const day = zeroPad(date.getDate());
|
|
const hour = zeroPad(date.getHours());
|
|
const minute = zeroPad(date.getMinutes());
|
|
const second = zeroPad(date.getSeconds());
|
|
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
|
}
|