1

I have a action method in controller which returns json result as:

public ActionResult GetByDids(int id)
{
    AngularMVCEntities _db = new AngularMVCEntities();
    var emps = _db.Employees.Where(x => x.Did == id).ToList();
    return Json(emps, JsonRequestBehavior.AllowGet);
}

And a code in angular js like:

app.controller('employeesController', function ($scope, $http) {
    $scope.GetEmployeesByDid = function (did) {
        alert('Get Employees By Id' + ' ' + did);
        $http.get('/Employees/GetByDids', { params: { id: did } }).then(function       (response) {
            $scope.Emps = response.data;
        });
    };
});

Output is: enter image description here

How to convert the json DATE to string?

2

2 Answers 2

1

Use this to convert JSON date

new Date(parseInt("/Date(813694500000)/".substr(6)))

Result : Sat Oct 14 1995 23:45:00 GMT+0530 (India Standard Time)

Sign up to request clarification or add additional context in comments.

Comments

0

var date = moment("/Date(1198908717056-0700)/").format("YYYY-MM-DD");
console.log(date);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Take a look at this Angular Moment Js and Moment Js for JSON date it might be helpful.

You can convert this as the below using moment js

var date = moment("/Date(1198908717056-0700)/").format("YYYY-MM-DD");

To use this you have to add Angular moment in your project and which is explained in above link how to add using nuget or bower or npm.

Please find above snippet as well

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.