Using date filter in angularjs to convert milliseconds to date

I have time in milliseconds which needs to be shown in proper date format in the UI. In angularjs we can use date filter to achieve this. We also need to convert milliseconds into proper javascript date format. So here is the code :

 
<span ng-bind="convertToDate(msg.time) | date:'medium'"></span>
 
$scope.convertToDate = function (stringDate){
      var dateOut = new Date(stringDate);
      dateOut.setDate(dateOut.getDate() + 1);
      return dateOut;
    };

Uday Ogra

Connect with me at http://facebook.com/tendulkarogra and lets have some healthy discussion :)

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *