Date format in angular js

后端 未结 4 610
星月不相逢
星月不相逢 2020-12-07 02:32

I am displaying date in this format using angular

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

how to display like Jan-dd-yyyy

相关标签:
4条回答
  • 2020-12-07 02:38

    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)
    
    0 讨论(0)
  • 2020-12-07 02:38

    Try this

     {{ date }} ,date:\'MMM-dd-yyyy HH:MM:ss\
    
    0 讨论(0)
  • 2020-12-07 02:43

    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
    
    0 讨论(0)
  • 2020-12-07 02:44

    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

    0 讨论(0)
提交回复
热议问题