How to format date in angularjs

2019-01-01 14:56发布

I want to format date as mm/dd/yyyy. I tried the following and none of it works for me. Can anyone help me with this?

reference: ui-date

<input ui-date ui-date-format="mm/dd/yyyy" ng-model="valueofdate" /> 

<input type="date" ng-model="valueofdate" />

14条回答
千与千寻千般痛.
2楼-- · 2019-01-01 16:01

This will work:

{{ oD.OrderDate.replace('/Date(','').replace(')/','') | date:"MM/dd/yyyy" }}

NOTE: once you replace these then remaining date/millis will be converted to given foramt.

查看更多
不再属于我。
3楼-- · 2019-01-01 16:01

see angular date api : AngularJS API: date


The Angular - date filter:

Usage:

{{ date_expression | date  [: 'format']  [: 'timezone' ] }}


Exampe:

Code:

 <span>{{ '1288323623006' | date:'MM/dd/yyyy' }}</span>

Result:

10/29/2010
查看更多
登录 后发表回答