'Getting different datetime in different region while using the timespan of same date returned from de-serialized Json object

I am getting different dates as a result while displaying it in the UI. I am getting a de-serialised json object which contains date time in the format of

row.Date => {1/1/2021 12:00:00 AM}

the same date I was displaying in the UI like

var startDate = row.Date != null && row.Date != undefined ? moment(row.Date).format('MM/DD/YYYY') : "";

I was checking this by changing my local time zones. I have tried with PST,CST,AT,EST,UTC-12:00 International Date Line West, UTC+14:00 Kiritimati Island.

I have tried the following scenarios to remove the offset while de-serializing the json object but still it shows the date as {1/1/2021 12:00:00 AM}

public JsonSerializerSettings SeralizerSettings = new JsonSerializerSettings() { DateTimeZoneHandling = DateTimeZoneHandling.Utc,DateParseHandling = DateParseHandling.DateTime };

or

public JsonSerializerSettings SeralizerSettings = new JsonSerializerSettings() { DateParseHandling = DateParseHandling.DateTime };

All the time the de-serialized json returning date as {1/1/2021 12:00:00 AM} but in the UI it showing as 31/12/2020 for some timezones, it shows 01/01/2021 and for some other time zones it shows 01/02/2021 based on the time zones.

How can I handle this scenario? Please help with this. I need to get in all the time zones should show as same date ie; 01/01/2021 note: in JS the value of row.Date getting as a timespan.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source