Skip to content

Instantly share code, notes, and snippets.

@AlexZeitler
Created May 28, 2012 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexZeitler/2821442 to your computer and use it in GitHub Desktop.
Save AlexZeitler/2821442 to your computer and use it in GitHub Desktop.
Custom datetime formatting with JSON.NET and ASP.NET Web API
var config = GlobalConfiguration.Configuration;
var settings = new JsonSerializerSettings();
settings.Converters.Add(new IsoDateTimeConverter()
{
DateTimeFormat = "dd.MM.yyyy"
});
config.Formatters.Remove(config.Formatters.JsonFormatter);
config.Formatters.Add(new JsonNetFormatter(settings));
@BrunnoObristo
Copy link

Where can i put this code? A class? Controller?

@aburakbasaran
Copy link

WebApiConfig.cs

@hovermind
Copy link

For asp.net core web api Startup.cs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment