Reputation: 831
I have a class with the datacontract and datamember attributes applied to its properties, including a datetime, like so:
[DataMember]
public DateTime MyDate{get;set;}
I'm using ADO.NET inside a class the webapi controller uses to get the data from the database, like so
MyDate = Convert.ToDateTime(reader["mydate"]);
Say for instance the date in the database is 2016-01-21 16:30:00.000. When I display it in javascript, ie.
new Date(value.MyDate).toString('MM/dd/yyyy hh:mm:ss')
it shows up on screen as 2016-01-21 04:30:00.000. When I check the fiddler response, the JSON is returning 2016-01-21T16:30:00 for the "MyDate" property of the object. What am I doing wrong? Why isn't this showing up in military time?
Upvotes: 0
Views: 142
Reputation: 831
Changing the hours to upper case in the date format string, from 'MM/dd/yyyy hh:mm:ss' to 'MM/dd/yyyy HH:mm:ss' corrected the issue.
Upvotes: 2