角度剑道 UI 网格日期时间格式,采用 yyyy/MM/dd 从纪元时间开始



我正在使用Kendo UI GridAngular 6并从API获取数据,其中日期时间以纪元格式出现,如下所示:

x.items[0].EffectiveDate.$date = 1550719967

我正在下面html用于剑道网格列,排序也应该可以工作。我已经浏览了这个和这个链接,但没有解决问题。

如果有人遇到这种情况,请帮助我弄清楚。 提前谢谢。

<kendo-grid-column field="EffectiveDate" title="Effective Date" filter="date" format="{0:dd/MM/yyyy HH:mm:ss }" [style]="{'text-align': 'left'}" width="130">
<ng-template kendoGridCellTemplate let-dataItem>
{{ dataItem.EffectiveDate?.$date | date:'dd/MM/yyyy HH:mm:ss'}}
</ng-template> </kendo-grid-column>

你有错别字错误

x.items[0].EffectiveDate.$date = 15159I4400000

此值包含一个I15159'I'4400000

尝试使用1515914400000

<kendo-grid-column field="EffectiveDate" title="Effective Date" filter="date" format="{0:dd/MM/yyyy HH:mm:ss }" [style]="{'text-align': 'left'}"
width="130">
<ng-template kendoGridCellTemplate let-dataItem>
{{ getdateformat(dataItem.EffectiveDate.$date | date:'dd/MM/yyyy HH:mm:ss'}}
</ng-template>

getdateformat(utcSeconds){
if (utcSeconds == null || utcSeconds == "" || utcSeconds == undefined){
return "";
}
var d = new Date(0); // The 0 there is the key, which sets the date to the epoch
d.setUTCSeconds(utcSeconds);
return d;
}

将纪元转换为日期的参考

最新更新