search

Home  >  Q&A  >  body text

angular.js - How to format string type time in angularjs

The time I got is a string type Feb 21, 2017 5:10:09 PM
I want to format this character into "yyyy-MM-dd"
It is useless to write like this: {{data.time | date:'yyyy-MM-dd'}}
Solve

PHPzPHPz2812 days ago930

reply all(1)I'll reply

  • 巴扎黑

    巴扎黑2017-05-15 17:14:40

    var time = new Date("Feb 21, 2017 5:10:09 PM") ;
    var YMD = $filter('date')(time, 'yyyy-MM-dd');

    reply
    0
  • Cancelreply