mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-22 02:07:56 +00:00
18 lines
559 B
JavaScript
18 lines
559 B
JavaScript
/** @internal */
|
|
function zeroPad(value) {
|
|
return value.toString().padStart(2, '0');
|
|
}
|
|
/**
|
|
* @name formatDate
|
|
* @description Formats a date in CCYY-MM-DD HH:MM:SS format
|
|
*/
|
|
export 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}`;
|
|
}
|