ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Convert JSON Date to Date format using JavaScript and AngularJS in ASP.Net MVC<p>Hi&nbsp;mahesh213,</p> <p>Since you are dynamically populate columns and rows it is nopt possible to use filter.</p> <p>So to display the Date properly you need to convert it to Date before assigning to scope.</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">Database</span></strong></p> <p>For this example I have used of Northwind database that you can download using the link given below.</p> <p><a href="https://www.aspsnippets.com/Articles/Install-Microsoft-Northwind-and-Pubs-Sample-databases-in-SQL-Server-Management-Studio.aspx" target="_blank">Download Northwind Database</a></p> <p><strong><span style="text-decoration: underline;">Controller</span></strong></p> <pre class="brush: csharp">public class HomeController : Controller { // GET: /Home/ public ActionResult Index() { return View(); } public JsonResult GetEmployees() { NorthwindEntities entities = new NorthwindEntities(); var employees = entities.Employees .Select(x =&gt; new { Id = x.EmployeeID, Name = x.FirstName + &#34; &#34; + x.LastName, DOB = x.BirthDate, City = x.City, Country = x.Country }).ToList(); return Json(employees, JsonRequestBehavior.AllowGet); } }</pre> <p><strong><span style="text-decoration: underline;">View</span></strong></p> <pre class="brush: html">&lt;body&gt; &lt;link rel=&#34;stylesheet&#34; href=&#34;https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css&#34; /&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; var app = angular.module(&#34;MyApp&#34;, []); app.controller(&#34;MyController&#34;, [&#39;$scope&#39;, &#39;$http&#39;, function ($scope, $http) { $http.get(&#34;/Home/GetEmployees&#34;) .then(function (response) { for (var i = 0; i &lt; response.data.length; i++) { // Loop through each property in the Array. for (var property in response.data[i]) { if (response.data[i].hasOwnProperty(property)) { var resx = /Date\(([^)]+)\)/; // Checking Date with regular expresion. if (resx.test(response.data[i][property])) { // Setting Date in dd/MM/yyyy format. response.data[i][property] = ConvertJsonDateToDate(response.data[i][property]); } } } } $scope.Employees = response.data; }); function ConvertJsonDateToDate(date) { var parsedDate = new Date(parseInt(date.substr(6))); var newDate = new Date(parsedDate); var month = (&#39;0&#39; + (newDate.getMonth() + 1)).slice(-2); var day = (&#39;0&#39; + newDate.getDate()).slice(-2); var year = newDate.getFullYear(); return day + &#34;/&#34; + month + &#34;/&#34; + year; } } ]); &lt;/script&gt; &lt;div ng-app=&#34;MyApp&#34; ng-controller=&#34;MyController&#34;&gt; &lt;table class=&#34;table table-responsive&#34;&gt; &lt;thead&gt; &lt;tr&gt; &lt;th ng-repeat=&#34;(header, value) in Employees[0]&#34;&gt;{{header}}&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr ng-repeat=&#34;row in Employees&#34;&gt; &lt;td ng-repeat=&#34;cell in row&#34;&gt;{{cell}}&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/div&gt; &lt;/body&gt;</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><strong><span style="text-decoration: underline;"><img src="https://i.imgur.com/wsjS2iO.jpg" alt="" width="337" height="376" /></span></strong></p>https://www.aspforums.net:443/Threads/732311/Convert-JSON-Date-to-Date-format-using-JavaScript-and-AngularJS-in-ASPNet-MVC/https://www.aspforums.net:443/Threads/732311/Convert-JSON-Date-to-Date-format-using-JavaScript-and-AngularJS-in-ASPNet-MVC/Tue, 14 May 2019 01:30:15 GMT