如何在asp.net MVC中从Angular转换JSON日期 [英] How to convert json date from angular in asp.net mvc
本文介绍了如何在asp.net MVC中从Angular转换JSON日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在控制器中有一个操作方法,可将json结果返回为:
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);
}
还有角度js中的代码,例如:
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;
});
};
});
输出为:
如何将json DATE转换为字符串?
How to convert the json DATE to string?
推荐答案
使用此转换JSON日期
Use this to convert JSON date
new Date(parseInt("/Date(813694500000)/".substr(6)))
结果:1995年10月14日星期六格林尼治标准时间+0530(印度标准时间)
Result : Sat Oct 14 1995 23:45:00 GMT+0530 (India Standard Time)
这篇关于如何在asp.net MVC中从Angular转换JSON日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文