0

I have to define a date in my Student Object,like that:

var Students = new List<Student>
{
    new Student{ FirstName="Student ",dateBirth=DateTime.Today }
};
Students.ForEach(s =>
{
    s.ObjectState = Repository.Pattern.Infrastructure.ObjectState.Added;
    context.Students.Add(s);
    context.SaveChanges();
});

but I get this format when I run my project:

[{ FirstName: "Student ", dateBirth: "/Date(1457132400000)/" }]

the problem is that the date format is added exactly to the DataBase Student Table (like yyyy-MM-dd hh:mm:ss). I work with xampp MySQL any idea please how can I solve this problem,and display the date correctly?

user3821206
  • 609
  • 1
  • 9
  • 22
  • Possible duplicate of [ASP.NET MVC JsonResult Date Format](http://stackoverflow.com/questions/726334/asp-net-mvc-jsonresult-date-format) –  Mar 08 '16 at 03:23

1 Answers1

1

Try formatting the date time like this:

new Student{FirstName="Student ",dateBirth=DateTime.ToString("MMMM dd, yyyy")}

You can read up on the details here.

Custom Date and Time Strings

andre mcgruder
  • 1,120
  • 1
  • 9
  • 12