[script, webapp]时间本地时区格式化 (#35)

This commit is contained in:
tomsun28
2022-03-17 15:09:08 +08:00
committed by GitHub
parent 88b03448e3
commit f710795f0f
13 changed files with 47 additions and 11 deletions

View File

@@ -0,0 +1,20 @@
import { formatDate, Location } from '@angular/common';
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'timezone'
})
export class TimezonePipe implements PipeTransform {
timeZone: string = 'Asia/Shanghai';
constructor() {
this.timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
if (this.timeZone == undefined) {
this.timeZone = 'Asia/Shanghai';
}
}
transform(value: any): string {
return formatDate(value, 'YYYY-MM-DD HH:mm:ss', 'zh-cn');
}
}