asp core 3.1 set global default timezone? #42153
-
How to specify the global timzone? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 26 replies
-
It has to be done through the User settings or the machine admin. We don't have API to set the default time zone on the machine because it need a specific privilege to do it which is turned off by default. As user if you want to change the TZ from the settings you may follow the steps https://support.microsoft.com/en-us/help/4026213/windows-how-to-set-your-time-and-time-zone. If you want to do it by APIs, you may consider pinvoke to https://docs.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-settimezoneinformation but you have to work getting the needed privlage before doing so or the API will fail. |
Beta Was this translation helpful? Give feedback.
-
There is a backend API (asp netCore 3.1 + EFCore) works on centos-> kestrel -> nginx. |
Beta Was this translation helpful? Give feedback.
-
@EvgenyPrikhodko what is your scenario that need to run with different time zone than TimezoneOS? I am not familiar with what If you want to do that for testing purpose, one way to do it is using the Reflection to set the field https://source.dot.net/#System.Private.CoreLib/TimeZoneInfo.cs,65. |
Beta Was this translation helpful? Give feedback.
-
please register my wish. |
Beta Was this translation helpful? Give feedback.
-
I'm a bit late, but if you only need Linux support for this, .NET respects the The value of TZ can basically be any file under |
Beta Was this translation helpful? Give feedback.
-
@PathogenDavid what is your scenario you want to use this for? |
Beta Was this translation helpful? Give feedback.
It has to be done through the User settings or the machine admin. We don't have API to set the default time zone on the machine because it need a specific privilege to do it which is turned off by default.
As user if you want to change the TZ from the settings you may follow the steps https://support.microsoft.com/en-us/help/4026213/windows-how-to-set-your-time-and-time-zone.
If you want to do it by APIs, you may consider pinvoke to https://docs.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-settimezoneinformation but you have to work getting the needed privlage before doing so or the API will fail.