一:组件日期格式化:
ts中调用:
import {DatePipe} from "@angular/common";
@Component({
providers: [DatePipe],
})
export class CustomerManageComponent {
constructor(private datePipe:DatePipe) {
}
}
let dateStr= this.datePipe.transform(new Date(),"MM/dd/yyyy");
二:HTML日期格式化:
{{dateStr | date: 'yyyy-MM-dd'}}