1 | // Copyright 2017-2022 @polkadot/util authors & contributors
|
2 | // SPDX-License-Identifier: Apache-2.0
|
3 |
|
4 | /** @internal */
|
5 | function zeroPad(value) {
|
6 | return value.toString().padStart(2, '0');
|
7 | }
|
8 |
|
9 | export function formatDate(date) {
|
10 | const year = date.getFullYear().toString();
|
11 | const month = zeroPad(date.getMonth() + 1);
|
12 | const day = zeroPad(date.getDate());
|
13 | const hour = zeroPad(date.getHours());
|
14 | const minute = zeroPad(date.getMinutes());
|
15 | const second = zeroPad(date.getSeconds());
|
16 | return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
17 | } |
\ | No newline at end of file |