如何格式化angularjs日期

编程入门 行业动态 更新时间:2024-10-09 08:36:32
本文介绍了如何格式化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日

您可以看到支持的日期格式in源的日期过滤器。

的修改的:

如果你想(如果你使用的日期选择器,或只是想使用它的格式不清晰),以获得在日期选择正确的格式,这些支持的格式字符串在这里:的api.jqueryui/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.

demo

// 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: api.jqueryui/datepicker/

更多推荐

如何格式化angularjs日期

本文发布于:2023-05-28 00:48:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/308266.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:日期   angularjs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!