angular ts processing date format

Introduced DatePipe

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

Add provider

@Component({  
  providers: [DatePipe]
})

Added to the constructor

  constructor(private datepipe: DatePipe) {

  }

use:

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

 

Guess you like

Origin www.cnblogs.com/loaderman/p/11270331.html