In my Sql Server I have a column that has a date data type and here is a sample 2017-09-28. I created a model with this as display format:
[Display(Name = "Enroll Date")]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime CreationDate { get; set; }
and a controller in my angular controller:
var app = angular.module("MyApp", []);
app.controller("PdfController", function($scope, $http) {
$scope.message = "";
$scope.records = null;
$http({
method: 'GET',
url: '/Pdf/GetData'
}).then(function(result) {
$scope.records = result.data;
},
function(error) {
$scope.message = "Error in retrieving data @error: " + error;
});
})
then in my view, I used the ng-repeat like so:
<tr ng-repeat="record in records">
<td>{{record.Id}}</td>
<td>{{record.RfidNumber}}</td>
<td>{{record.RfidTag}}</td>
<td>{{record.AccountName}}</td>
<td>{{record.CreationDate | date:'dd/MM/yyyy'}}</td>
<td>{{record.EncodedBy}}</td>
</tr>
Why is it that in my table I get this value /Date(1506528000000)/ and I cannot get it to be formatted to dd/MM/yyyy? I tried setting my model to be public string CreationDate { get; set; }. It gives me the date but with 12:00 AM and I do not need the time. Can you help please? Thank you.