File size: 949 Bytes
db242f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
export function DateFormat(time: string | number): string {
  const date = new Date(time);

  const day: string = ('0' + date.getDate()).slice(-2);
  const month: string = ('0' + (date.getMonth() + 1)).slice(-2);
  const year: number = date.getFullYear();

  const hours: string = ('0' + date.getHours()).slice(-2);
  const minutes: string = ('0' + date.getMinutes()).slice(-2);
  const seconds: string = ('0' + date.getSeconds()).slice(-2);

  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}

export function DateFormat2(time: string | number | Date): string {
  const date = new Date(time);

  const day: string = ('0' + date.getDate()).slice(-2);
  const month: string = ('0' + (date.getMonth() + 1)).slice(-2);
  const year: number = date.getFullYear();
  const hours: string = ('0' + date.getHours()).slice(-2);
  const minutes: string = ('0' + date.getMinutes()).slice(-2);
  return `${month}-${day} ${hours}:${minutes}`;
}