angular ts处理日期格式

引入DatePipe

import {DatePipe} from '@angular/common';  

添加provider

@Component({  
  providers: [DatePipe]
})

添加到构造方法中

  constructor(private datepipe: DatePipe) {

  }

使用:

this.datePipe.transform(_date,'yyyy-MM-DD') ;

猜你喜欢

转载自www.cnblogs.com/loaderman/p/11270331.html