0

When using dynamic/JObject the Json date will be automcatily converted to a localized date. Is it possible to turn that off by in appsettings?

curl http://localhost:64233/api/nets/test \ 
 -H 'content-type: application/json; charset=utf-8' \
 -d '{ 
 "dateTime": "2017-06-14T09:20:22+0000" 
}'
[HttpPost("test")]
public async Task<dynamic> TestAsync([FromBody] dynamic request)
{
 String dateTime = request.dateTime; <--- dateTime "06/14/2017 11:20:22" 
...
asked Jun 14, 2017 at 12:33

1 Answer 1

1

You can change how JSON serialization handles times zones in your Startup class by configuring AddJsonOptions in ConfigureServices method.

public void ConfigureServices(IServiceCollection services)
{
 services.AddMvc().AddJsonOptions(options =>
 {
 options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
 });
}
answered Jun 14, 2017 at 14:40

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.