ABP Commercial 7.4.2 / Blazor Server / EF / Non tiered / Separate Host and Tenant DBs / Lepton Theme
Hi,
Our entire user base will always be located in the same time zone which is different than UTC and we would like the end user to always see their local time (East US).
We've read https://docs.abp.io/en/abp/latest/Timing and still are unsure of how to handle the following scenario...
In local development, we can convert ABP stored UTC values as pages load and everything works correctly, however this approach doesn't work when we deploy to Azure.
This is because the environments running in Azure have a local time of UTC. So we can't use CreationDateTime.ToLocalTime()
as it will always return a UTC time instead of East US.
Is there anyway around this or a certain recommended approach?
Thanks in advance.
2 Answer(s)
-
0
Hello Baslessi75,
You cannot use any functions which use the localtime of the machine, because when deploying to the cloud this could be different. I have personally witnessed this issue with my own projects too.
In general the guideline is that you manage everything in UTC until it is displayed to the user. This means using Javascript to detect the users timezone in the browser https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset
There is a Blazor library that can also take care of this for you. https://github.com/dustout/BlazorTime
-
0
Thanks for confirming IanW.
We came up with an approach similar to what you described.