get current date with 'yyyy-MM-dd' format in Angular 4

前端 未结 10 977
孤城傲影
孤城傲影 2020-12-23 20:35

How i can get the current date with a specific format \'yyyy-MM-dd\', for today by example i with that the result be: \'2018-07-12\', with using just the command

<         


        
10条回答
  •  南方客
    南方客 (楼主)
    2020-12-23 20:43

    you can try doing this.


    component.ts

    currentDate = new Date();
    

    component.html

    {{currentDate | date:'yyyy-MM-dd'}}
    

提交回复
热议问题