最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Date format in angular js - Stack Overflow

programmeradmin5浏览0评论

I am displaying date in this format using angular

{{ date }} ,date:\'MM-dd-yyyy HH:MM:ss\

how to display like Jan-dd-yyyy using angular

Is there any dirct way to do using angular js- (Using normal jquery i am able to do)

I am displaying date in this format using angular

{{ date }} ,date:\'MM-dd-yyyy HH:MM:ss\

how to display like Jan-dd-yyyy using angular

Is there any dirct way to do using angular js- (Using normal jquery i am able to do)

Share Improve this question asked Jul 17, 2013 at 7:44 PrashobhPrashobh 9,54215 gold badges64 silver badges91 bronze badges 2
  • Please refer this link friend docs.angularjs.org/api/ng.filter:date may be this one help you – snowp Commented Jul 17, 2013 at 7:49
  • Hi i created some custom filters and updated here angulartutorial.net/2014/04/… – Prashobh Commented Apr 23, 2015 at 6:51
Add a comment  | 

4 Answers 4

Reset to default 11

use Angular filter of date.

{{date  | date:'MM-dd-yyyy HH:MM:ss'}}

See the following link.

http://docs.angularjs.org/api/ng.filter:date

Well,

according to the docs, you have a builtin filter in angular, called date:

<p>{{Date.now() | date:'yyyy'}}

would render to:

<p>2013</p>

The yyyyin this case can be any format string documented. In the example you gave, this would be:

{{date | date: 'MMM-dd-yyyy'}} # => "Jan-21-2013" (if date was a date object for this day)

For custom date:

$scope.user.dob = new Date('1980', '12' ,'10');  // controller code

 {{user.dob | date : 'MMM-dd-yyyy'}}  // Dec-10-1980

For current date:

 $scope.user.current= new Date();  // controller code

 {{user.current | date : 'MMM-dd-yyyy'}}  // Current date in given format

Try this

 {{ date }} ,date:\'MMM-dd-yyyy HH:MM:ss\
发布评论

评论列表(0)

  1. 暂无评论