//Angular日期在TypeScript中格式化转换应用
//!...!
// 1.import { DatePipe } from '@angular/common';
// 2.private datePipe: DatePipe;
// 3.模块中将其providers: [DatePipe]添加;
//4. formatDateFun(date) {return this.datePipe.transform(date, 'yyyy-MM-dd');}
//!...!
//!...!
// 1.import { formatDate } from '@angular/common';
// 2.formatDateFun {return formatDate(date, 'yyyy-MM-dd', this.locale);}
// 3.模块中将其providers:[{provide: LOCALE_ID, useValue: 'zh-Hans' }]配置。
// formatDate(value: string | number | Date, format: string, locale: string, timezone?)
//value :要格式化的日期
//format: 日期时间格式,使用预定义选项或自定义格式字符串(如:YYYY-MM-DDThh:mm:ssTZD...);
// 参照 https://www.w3.org/TR/NOTE-datetime
//locale: 区域代码;
//timezone: (选填) 时区;
//!...!
Angular 在 TS中转换时间
最新推荐文章于 2024-04-26 15:01:42 发布