Format Date Time in Angular 2

How to display date in Angular2?

{{}} DTE

He prints the date 2014-10-10T11: 42: 28.000Z

while I need it prints like

October 10, 2015

+6
source share
3 answers

you can use moment.js as a third party.

tube amDateFormat

import {DateFormatPipe} from 'angular2-moment'; @Component({ selector: 'app', pipes: [DateFormatPipe], template: ` Last updated: <time>{{myDate | amDateFormat:'LL'}}</time> ` }) Prints Last updated: January 24, 2016 

Documentation: https://github.com/urish/angular2-moment

+4
source

just use a pipe filter with ur {{dte}} ...

just use {{dte | date: 'MM / dd / yyyy @h: mma'}}

he will give you the desired result :)

+8
source

Use the data feed :

 {{dte | date}} 

You can choose a predefined format (e.g. shortDate ):

 {{dte | date:'mediumDate'}} 

Or specify your own format:

 {{dte | date:'MM dd, yyyy'}} 
+7
source

All Articles