Newtonsoft date parsing issue causes date to be off by one day

I am encountering an issue in my TypeScript project where the date selected by users is not being parsed correctly.

For example: (JSON)

"IssueDate":"Wed Jan 18 2017 00:00:00 GMT+0200 (Jordan Standard Time)"

However, when I try to parse the object using Newtonsoft in my controller, the resulting date property is always showing one day less than expected.

IssueDate: {1/17/2017 10:00:00 PM}

I'm puzzled as to why this discrepancy is happening. Could it be a configuration issue with Newtonsoft that's causing this mismatch?

Answer №1

Here's a tip for your register method in the webapi project:

Adjust GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.DateTimeZoneHandling to DateTimeZoneHandling.Local;

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Easily generate a component directory complete with all essential files in just a few simple clicks

In my work with React and the typical app structure, I utilize a directory called src/components to store all of my React components. I am looking for a way to streamline the process of creating new components. I would like to be able to generate a compon ...

What is the process for converting a JSON string to an Array in Android development?

Seeking a solution to a common issue with parsing JSON strings. I have been searching for examples, but none seem to work for my specific case: {"id": "5", "name": "John"} Is there a way to transform this JSON string into an array or map in order to ach ...

What is causing the role="status" attribute to malfunction?

I'm having an issue with the role="status" attribute in my code. When using a screen reader, the paragraph text doesn't get read once it's appended to the body. index.html: <!DOCTYPE html> <html> <head> <title> ...

Using SimplyJS and XML: extracting the value of a specific key

Hey there, I wanted to update you on my progress with the Pebble Watch project. I've switched over to using an official external API to make HTTP requests for values, and now I'm receiving results in XML format instead of JSON. Here's a ...

New update in Next.js version 13.4 brings a modification to routing system

I'm currently working with Next.js 13.4 and an app directory. I'm trying to implement a centrally located loader that will show whenever there is a route change anywhere within the app. Since routes/navigation don't have event listeners, I&a ...

An AJAX request receives a "400 Error: Bad Request" status code

Recently delving into the realm of jquery, I've encountered a 400 bad request error (identified in the browser console). $("form#upload").submit(function(){ var token = $("meta[name='_csrf']").attr("content"); var header = $("meta[name=&apo ...

Certain images are being rotated in a counter clockwise direction by 90 degrees

Users can upload images of their items, but some pictures appear rotated 90 degrees counter-clockwise after uploading. This could be due to the way the photos were taken on an iPhone. Is there a simple solution to correct this rotation issue? The following ...

Troubleshooting issues with AngularJS $watch not triggering properly

Even though Deep watch has been activated in the factory, it is not triggering. What steps can be taken to resolve this issue and ensure that an event is triggered when the 'name' value changes? Javascript Code: var app = angular.module('a ...

Looking for assistance in stopping the parent onclick event from triggering when clicking on a child div

Is there a way to prevent the parent onclick event from triggering when clicking on a child div? Here's the scenario: <div onclick='parentClick()'> <div onclick='childClick()'> <div onlick='subchildClic ...

Difficulties encountered while converting JSON String to objects in Swift

After doing extensive research and referencing various tutorials, I attempted to parse a JSON String into usable objects in Swift by utilizing code snippets found online. Below is the code snippet: func parseJson(json: String) -> [AnyObject] { let ...

Returning multiple recordsets in SQL 2016 with JSON support

Trying to utilize MS SQL 2016 for fetching an array of JSON objects containing all table information. However, the query seems to be returning a duplicate array of record sets instead of just one with the queried data. var sql = require('mssql/msnode ...

Troubleshooting issues when testing Angular services using Jasmine and Chutzpah

I've been facing some challenges while attempting to test my AngularJs services with Jasmine as I encounter various errors consistently. In an effort to troubleshoot, I decided to create a simple Sum service for testing purposes but unfortunately, the ...

Exploring the challenges of working with nested JSON data and utilizing Codable for parsing

*I'm having trouble using Codable to parse JSON data that is particularly complex. The issue lies with the "route_polyline" field. Problem: CodingKeys(stringValue: "route_polyline", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], deb ...

Utilizing a foreach loop to control the behavior of two distinct radio buttons as a unified

Can someone help me with a code containing a 5 star rating system (radio button) for two different questions? The issue is that the ratings for each question are linked, so when I make a selection in one question, it clears the selection in the other. It& ...

Solving generic type interface in ServiceStack Request filter

Is it possible to resolve an interface in a ServiceStack request filter that uses a generic type dynamically retrieved from the DTO of the request? I have multiple validators defined in my assembly that use an interface with a generic type, like this: Add ...

Show each individual layer from a KMZ file on a map with the ArcGIS API for JavaScript

Can I selectively show specific layers from a kmz file on my map? My current setup involves using the ArcGIS API for JavaScript. Specifically, I want to display only folders related to the current day outlook from a KMZ file provided by the NWS. There are ...

How come when utilizing jQuery to call a PHP function, the output received is the actual PHP code?

I'm currently working with a php file that has the following code: if(isset($_GET['fn'])) { if($_GET['fn']=='generarxml') generarxml(); else exit; } function generarxml() { ...

What are some ways to specialize a generic class during its creation in TypeScript?

I have a unique class method called continue(). This method takes a callback and returns the same type of value as the given callback. Here's an example: function continue<T>(callback: () => T): T { // ... } Now, I'm creating a clas ...

Strategies for re-rendering a React component when the useState value remains the same or retains its previous value

I am currently using a useState hook to store the value of selectFolderId: const [selectFolderId, useSelectFolderId] = React.useState(documentStore.id) Despite trying to update selectFolderId with the new value from DocumentStore by using a useEffect hook ...

Maintaining duplicate values in a JSON stringify operation: Tips for retention

Server responses are being received in JSON format, which may contain objects with duplicate keys. When displaying the results, I noticed that only the last value for duplicate keys was showing up. After investigating, I realized this was due to using the ...