Dates without time in ASP.NET Web API’s JSON output

If you need this to only affect a particular field, create a converter type first:

public class OnlyDateConverter : IsoDateTimeConverter
{
    public OnlyDateConverter()
    {
        DateTimeFormat = "yyyy-MM-dd";
    }
}

and then add this attribute to whatever fields/properties you want this for:

[JsonConverter(typeof(OnlyDateConverter))]

Leave a Comment