-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run the application with a different time zone. #42241
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
How hard is it to do I'm not exactly sure why this feature is required and how much value this holds, other than being (what looks to me) a hacky workaround for a specific problem that I'm unsure if it is common. Could you perhaps elaborate a bit more about your scenario? |
Not difficult. but in my version does not solve the problem, for example, I have other applications on the same server that may live in a different time zone
It is very simple, take an example, hosting does not always have access to the OS, or the server uses UTC, and the application should, for example, be in utc + 3.
It is understandable here, if the application uses other people's native libraries, I agree, in this case you need to solve the issue differently. Not my case
It's very simple, we have 3 web servers running asp.net Core. I needed to launch another application, but it turned out that a different time zone was needed. Moreover, this application will be launched in 5 instances in 5 different time zones. That would not buy 5 servers, this option will save money and time. |
If you can use Docker, you can set the timezone for the container. However....
It's not going to help in your case (since you don't have the original source to modify), but generally the server/os/process timezone should be completely irrelevant. You want some way for your application to retrieve/use an entity timezone - it figures out what timezone it needs based on what entity it's processing, and uses that. Potentially, that means that you'd only launch one instance of the application (and definitely makes your server config easier). Some legacy applications were definitely written assuming a specific server timezone, but modern applications should not be written that way. |
It's worth noting that the runtime already supports the The value of TZ can basically be any file under /usr/share/zoneinfo. (Or an absolute path to a custom timezone file.) This functionality is implemented by |
@PathogenDavid what is your scenario you want to use this for? |
@tarekgh I have 0 use for this feature, I just stumbled upon the discussion and thought I'd mention |
Thanks, but your solution doesn't work for me. |
@EvgenyPrikhodko Not sure what to tell you, works fine for me on WSL. |
Thank you, we know this option. |
Instead of adding a new argument to dotnet run, why not just make Windows consistent with Linux so that if the TZ environment variable is set in Windows, dotnet automatically uses that to determine the system timezone? |
This is a clever idea. The only concern with that setting such environment variable is going to affect other applications running on the same machine if the environment variable is set per user or machine. On Linux is ok as this is documented behavior for the OS. But Windows doesn't support that and can be a surprise for some applications. Maybe the best here is to do that with a config switch? |
I guess it is kinda a major change as it could technically be a breaking change. It would be really nice if you didn't have to specify a command line argument to make this work though. I hate that for every OS except windows, TZ sets the timezone. Why does windows have to be so difficult? |
agree.
Did you request that from Windows before? :-) |
Run application in a different time zone
Problems:
For example like this:
dotnet myapp.dll --timezone "Morocco Standard Time"
Optional:
This discussion was discussed here
The text was updated successfully, but these errors were encountered: