如何格式化angularjs日期 [英] How to format date in angularjs
问题描述
我要格式化日期 MM / DD / YYYY
。我尝试以下,没有它为我工作。
谁能帮我这个?
参考: UI最新
<输入UI更新UI的日期格式=MM / DD / YYYYNG-模式=valueofdate/><输入类型=日期NG模型=valueofdate/>
Angular.js有一个内置的日期过滤器。
//在你的控制器:
$ scope.date ='20140313T00:00:00';//在你看来,date属性,与日期过滤器和过滤格式MM / DD / YYYY
< p NG绑定=日期|日期:'MM / DD / YYYY'>< / P>//产生
2014年3月13日
您可以看到支持的日期格式<一个href=\"https://github.com/angular/angular.js/blob/dc57fe97e1be245fa08f25143302ee9dd850c5c9/src/ng/filter/filters.js#L310\">in源的日期过滤器。
的修改的:
如果你想(如果你使用的日期选择器,或只是想使用它的格式不清晰),以获得在日期选择正确的格式,这些支持的格式字符串在这里:的https://api.jqueryui.com/datepicker/
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" />
Angular.js has a built-in date filter.
// in your controller:
$scope.date = '20140313T00:00:00';
// in your view, date property, filtered with date filter and format 'MM/dd/yyyy'
<p ng-bind="date | date:'MM/dd/yyyy'"></p>
// produces
03/13/2014
You can see the supported date formats in the source for the date filter.
edit:
If you're trying to get the correct format in the datepicker (not clear if you're using datepicker or just trying to use it's formatter), those supported format strings are here: https://api.jqueryui.com/datepicker/
这篇关于如何格式化angularjs日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!