I have a data type of type Moment in Angular, everytime it displays in Angular, it exhibits as
<div>{{dateStart}}</div>
Fri Mar 08 2019 20:24:35 GMT-0800
How do I display to show, '3/8/2019' ?
If converting in Typescript, we have to take existing class, and recreate new class with last two data types as date. Just curious if there is Displayformat Angular in HTML or Pipe function? Where its converted in HTML?
export class Address {
fullName: string;
mailingAddress: string;
phoneNumber: string;
emailAddress: string;
dateStart?: moment.Moment;
dateEnd?: moment.Moment;
Resource questions:
Angular: Format Moment to show as Date in html
Convert string to date using moment.js
How to set today date and time as default in angular-moment-picker
I have a data type of type Moment in Angular, everytime it displays in Angular, it exhibits as
<div>{{dateStart}}</div>
Fri Mar 08 2019 20:24:35 GMT-0800
How do I display to show, '3/8/2019' ?
If converting in Typescript, we have to take existing class, and recreate new class with last two data types as date. Just curious if there is Displayformat Angular in HTML or Pipe function? Where its converted in HTML?
export class Address {
fullName: string;
mailingAddress: string;
phoneNumber: string;
emailAddress: string;
dateStart?: moment.Moment;
dateEnd?: moment.Moment;
Resource questions:
Angular: Format Moment to show as Date in html
Convert string to date using moment.js
How to set today date and time as default in angular-moment-picker
Share Improve this question edited Nov 9, 2019 at 4:37 asked Nov 9, 2019 at 4:29 user12250118user122501181 Answer
Reset to default 6You need to use the date pipe
as,
{{dateStart | date: 'MM/dd/yyyy'}}
To remove leading zeros, do this
{{dateStart | date: 'M/d/yyyy'}}