javascript - Angular: Format Moment to show as Date in html - Stack Overflow

I have a data type of type Moment in Angular, everytime it displays in Angular, it exhibits as <div&

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 user12250118user12250118
Add a ment  | 

1 Answer 1

Reset to default 6

You need to use the date pipe as,

{{dateStart | date: 'MM/dd/yyyy'}}

To remove leading zeros, do this

{{dateStart | date: 'M/d/yyyy'}} 

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745306992a4621770.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信