Prerequisites
Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.
- What is your product version? 8.8
- What is your product type (Angular or MVC)? MVC
- What is product framework type (.net framework or .net core)? .net Core
On submitting the data delow to an API post method using the swagger interface the time zone (+12:00) information is stripped out and has converted it to 2021-06-21T12:00:00+00:00.
{ "dateTime":"2021-06-21T00:00:00+12:00", }
If I view the Audit Log I can see that the data is already altered to 2021-06-20T12:00:00+00:00.
This is having the effect of showing date controls getting confused and showing 2021-06-19
Our web servers are running on MS Azure Web apps
7 Answer(s)
-
0
Hi,
AspNet Zero only modifies date values if you use UtcClockProvider or LocalClockPrivider. If you are using UtcClockProvider, you can switch to LocalClockProvider, see https://aspnetboilerplate.com/Pages/Documents/Timing.
If you don't want AspNet Zero to modify these values at all, you can use UnspecifiedClockProvider. In that case, ASP.NET Core will handle string to datetime conversion.
-
0
Thanks,
Each of our tenants must be able to set their own time zone, so we are restricted to using Clock.Provider = ClockProviders.Utc;
Client UTC = +12
The result we see is that if a userr enters a value of 2021-06-22 (no time value) the value as it passes into the API is converted to
dateTime: "2021-06-21T12:00:00+00:00",
-
0
Hi,
Still trying to find an answer for this
-
0
Hi,
The result we see is that if a userr enters a value of 2021-06-22 (no time value) the value as it passes into the API is converted to
dateTime: "2021-06-21T12:00:00+00:00",
This is the expected behaviour. The value is converted to UTC according to current user's timezone. And then, whe displaying the same value in UI, it must be converted to current user's timezone.
For example, in this case, value is saved to DB as
2021-06-21T12:00:00+00:00
. If another user logins to the system and have a timezone value as UTC, then the value2021-06-21T12:00:00+00:00
must be displayed to this user. If a user with UTC+6 logins, then that user will see2021-06-21T18:00:00+00:00
.So, probably you are posting value with a tenant with timezone UTC+12 and viewing the values with a tenant with timezone UTC. Could that be the case ?
-
0
How would you recommend dealing with standard and daylight savings? Potientially a date can show as the wrong day when this changes.
-
0
Also. Recommendations when running background jobs on tenant data where the function does not know the timezone? i.e a date time value sent in an email will show the original UTC date without considering the users timezone.
-
0
Hi,
For Daylight saving, if you are showind data on client side, JS libraries automatically handles this. For server side, I think ASP.NET Core doesn't handle it (I'm not %100 sure). In that case, you can use a library like NodaTime.
For background jobs, you can use https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp/Timing/Timezone/TimeZoneConverter.cs and convert UTC date to a user's timezone easily.