Desterilise JSON is auto-converting UTC time to local time

Hi All,

The string output that I am getting via HTTP request is - “2024-05-23T11:30:56-07:00”

But when I am deserialising JSON to get a key value pair, this value is auto-converting to “2024-05-24T00:00:56+05:30” i.e the local timezone.

Is there a way to retain the original timezoneinfo?

Hi @Pranav_Kende

Can you try like below

TimeZoneInfo.ConvertTime(DateTimeOffset.Parse(jsonObject("date").ToString), TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time")).ToString("yyyy-MM-ddTHH:mm:sszzz")

Cheers!!

Here you have used FindSystemTimeZoneById(“Pacific Standard Time”) because it is -7:00.

Here, we cannot predict the timezone from the API. Now we can see -7:00, but also can be -6:00, -5:00 etc

you can use the Serialization Config Parameter and block the parsing


grafik

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.