Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何获取Angular 2中的日期格式?_Angular_Typescript - Fatal编程技术网

如何获取Angular 2中的日期格式?

如何获取Angular 2中的日期格式?,angular,typescript,Angular,Typescript,我在服务器应用程序中,日期为2016年7月12日15:45:39 现在,我如何获得2016年7月12日的格式和模板输出 标记 <div *ngFor="let data of item"> <p>{{data.created_at}}</p> </div> {{data.created_at}} 显示格式 2016-12-07 15:45:39 以及如何筛选以在模板中获得2016-12-07?您可以使用DatePipe和y.M.d格式

我在服务器应用程序中,日期为2016年7月12日15:45:39

现在,我如何获得2016年7月12日的格式和模板输出

标记

<div *ngFor="let data of item">
   <p>{{data.created_at}}</p>
</div>

{{data.created_at}}

显示格式
2016-12-07 15:45:39


以及如何筛选以在模板中获得2016-12-07?

您可以使用
DatePipe
y.M.d
格式

<div *ngFor="let data of item">
   <p>{{data.created_at | date: 'y.M.d'}}</p>
</div>

{{data.created_在|日期:'y.M.d'}


Pankaj Parkar,非常感谢,我不知道这件事,对我来说是新的))@AccessDenied,很高兴帮助你,谢谢&干杯;)