-1

Convert a date format to normal date format like: 12-07-2017

My output is coming like:

/Date(1508896907290)

I am using angular js.

 {{list.DateStamp}}

any solutions??

convert binary format to general format?

I have tried a lot but not working.

      @*{{list.DateStamp | date:"MM/dd/yyyy 'at' h:mma"}}*@

 @*<span class="">{list.DateStamp | date}}</span>*@
asasasaa
  • 105
  • 2
  • 10
  • What you refer to as "binary format" is actually called "Unix timestamp" – Oliver Baumann Oct 27 '17 at 13:32
  • Possible duplicate of [How to format a JavaScript date](https://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date) – Ante Jablan Adamović Oct 27 '17 at 13:32
  • Can you please add little bit more code. If list.DateStamp prints a unix timestamp {{list.DateStamp | date:"MM/dd/yyyy 'at' h:mma"}} should actually work. What s the output you see when you print {{list.DateStamp}}? Can you also check if you have any console errors – Praveen Alluri Oct 27 '17 at 13:34
  • Possible duplicate of [function to convert timestamp to human date in javascript](https://stackoverflow.com/questions/19485353/function-to-convert-timestamp-to-human-date-in-javascript) – Oliver Baumann Oct 27 '17 at 13:35
  • DateStamp is in datetime format – asasasaa Oct 27 '17 at 13:43

1 Answers1

0

Use a custom filter like in below example:

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
  $scope.mydate = 1509046061730;
})
.filter('datfilter', function($filter) {
  return function(date, format) {
    return $filter('date')(new Date(date), format)
  }
})
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
  <h1>Orginal date: {{mydate}}</h1>
  <h1>Filtered date: {{mydate|datfilter:'dd.MM.yyyy'}}</h1>
</div>
ferhado
  • 2,067
  • 2
  • 8
  • 30