-1
public class Plans
    {
        public long PlanID { get; set; }

        public long? CompanyID { get; set; }

        public string PlanType { get; set; }

        public string PlanName { get; set; }        

        public bool? IsActive { get; set; }

        public int? CreatedBy { get; set; }

        public DateTime? CreatedDate { get; set; }       

        public int? CheckedBy { get; set; }            
    }              

    var date = [{
          0:
            BusinessType: "null"
            CheckedBy: null
            CheckedDate: null
            CompanyID: null
            CompanyName: "Swastik"
            CreatedBy: null
            CreatedDate: "/Date(1587383258707)/"    
        }];

Added Controller Method and ajax call from view for better assistance.Unable to find the way to do it. I am not able to find out how to extract date from above json string retrieved in jquery. Kindly assist me in that. Added my model class above that I am using. I am simply getting data by calling a procedure and rendering the data from controller to view using ajax call and populating the ajax call sucess data in controls.

jiga
  • 133
  • 10
  • 2
    This doesn't look like a valid object.. there is a key `0` without any value. Also, this is an array, not a JSON string. Please post the correct code and update your description accordingly. – palaѕн Apr 23 '20 at 08:39
  • Once you've fixed that this is likely a duplicate: https://stackoverflow.com/questions/726334/asp-net-mvc-jsonresult-date-format – Rory McCrossan Apr 23 '20 at 08:43

1 Answers1

1

An alternative Approach, what I do is create another property/ function in my Model.

your model in asp

    public class YourModel{
       public DateTime CreatedDate {get;set;}
        // if you want through model
        public string FormattedCreatedDate {get { return CreatedDate.ToString("dd-MM-yyyy");}} 
        // or through functions
        public string GetFormattedCreatedDate(){
            return CreatedDate.ToString("dd-MM-yyyy");
        }
    }
Josh
  • 223
  • 1
  • 6