Search code examples
javascriptangularjsangularjs-filter

How to change: 2018-01-03 21:00:00 to 3 January 21:00 with AngularJs


What should I do with 2018-01-03 21:00:00 to get 3 January 21:00(without year)


Solution

  • you can use the date pipe: https://docs.angularjs.org/api/ng/filter/date

    {{yourDate | date: 'dd MMMM HH:mm'}}
    

    Example with your API:

    http.get(url).then(function(res) {
      $scope.data = res.list;
    
      angular.forEach($scope.data, function(item) {
        item.dt_txt = new Date(item.dt_txt);
      });
    });