I cerated odata webservice in C# the JSON response return datetime field formatted like :
"updated": "2017-01-25T01:40:04",
how can I format it like "2017-01-25 01:40" ?
I cerated odata webservice in C# the JSON response return datetime field formatted like :
"updated": "2017-01-25T01:40:04",
how can I format it like "2017-01-25 01:40" ?
I assume you are using Newtonsoft.Json and that you want the format to be global (apply the format to every date)
Put this in the Application_Start
method:
HttpConfiguration config = GlobalConfiguration.Configuration;
config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(
new IsoDateTimeConverter() { DateTimeFormat = "yyyy-MM-dd HH:mm" });
More info in this possible duplicate question