---
title: "Send date from my front end (angular) to c# .net datetime (webapi)"  
description: "Send date from my front end (angular) to c# .net datetime (webapi)"  
author: "Lillian Martin"  
published: 2014-11-21  
updated: 2014-11-21  
canonical: https://www.mindstick.com/forum/12668/send-date-from-my-front-end-angular-to-c-sharp-dot-net-datetime-webapi  
category: "asp.net"  
tags: ["c#", ".net", "json", "angular js"]  
reading_time: 2 minutes  

---

# Send date from my front end (angular) to c# .net datetime (webapi)

On my front-end I have a [HTML input](https://www.mindstick.com/forum/157343/how-to-prevent-a-user-from-adding-same-character-over-and-over-in-html-input-box-using-javascript) box where the user can enter a date. This adds data to my [AngularJS](https://www.mindstick.com/forum/33926/use-angularjs-without-scope-in-mvc) modal and I then try to send it to the [server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) as a [JSON object](https://www.mindstick.com/forum/699/how-to-parse-into-json-object-using-json-parse-in-node-js) when the [user clicks](https://answers.mindstick.com/qa/34556/if-a-user-clicks-all-the-google-ads-on-my-site-is-it-foul) save.

On the server I have used this which I think modifies the way dates are expected. All I know is that it allows AngularJS to nicely read the dates coming from the back-end.

```
     config.SuppressDefaultHostAuthentication();        config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));        config.Formatters.Remove(config.Formatters.XmlFormatter);        var json = config.Formatters.JsonFormatter;        json.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();        json.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;        json.SerializerSettings.Converters.Add(new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-ddTHH:mmZ" });
```

Does [anyone](https://www.mindstick.com/articles/23207/how-to-find-the-best-fit-job-for-anyone) have any ideas how I can take a date entered into the input box in a format such as YYYY-MM-DD, modify in some way and then pass this to the server and have the server read it as a [datetime](https://www.mindstick.com/forum/12949/how-to-validate-if-a-datetime-field-is-not-null-empty)?

The [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) I have is that I am not sure how I can modify the YYYY-MM-DD date. When I try entering in a date like "2011-12-31" it does not get [accepted](https://yourviews.mindstick.com/view/80674/whatsapp-accepted-as-most-popular-app-worldwide) by the server and the column that it should be entered into shows a [null value](https://www.mindstick.com/forum/23045/document-body-appendchild-has-a-null-value) for the date.

## Replies

### Reply by Pravesh Singh

Have you ever tried to create a subclass of IsoDateTimeConverter? Try this:

```
public class MyJsonDateTimeConverter : IsoDateTimeConverter{    public MyJsonDateTimeConverter()    {        base.DateTimeFormat
= "yyyy-MM-dd";    }}
```

Then use it in place of the last line:

json.SerializerSettings.Converters.Add(new MyJsonDateTimeConverter());

Hope this helps :)


---

Original Source: https://www.mindstick.com/forum/12668/send-date-from-my-front-end-angular-to-c-sharp-dot-net-datetime-webapi

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
