RI Khan RI Khan - 1 month ago 22
AngularJS Question

AngularJs Convert string datetime to datetime object

I need to convert "10-28-2016 10:27:14 AM" string datetime to datetime Fri Oct 28 2016 12:04:16 in angularJs
Pls Help

Answer

view

<p>{{'10-28-2016 10:27:14 AM' | filter}}</p>

filter and controller

angular
    .module('myApp',[])
    .run(function($rootScope){
        $rootScope.title = 'myTest Page';
    })
    .controller('testController', ['$scope', function($scope){

    }]).filter('filter', function($filter) {

return function(input) {

var date = new Date(input);
return($filter('date')(date, 'EEE MMM dd yyyy HH:mm:ss') );
  }
});
Comments