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
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
just use a pipe filter with ur {{dte}} ...
just use {{dte | date: 'MM / dd / yyyy @h: mma'}}
he will give you the desired result :)
Use the data feed :
{{dte | date}}
You can choose a predefined format (e.g. shortDate ):
shortDate
{{dte | date:'mediumDate'}}
Or specify your own format:
{{dte | date:'MM dd, yyyy'}}