How in ASP.NET Web API application .NET 8, Set server time in UTC?
I have an Web API application, I would like to operate with utc timezone in application
4 Replies
You normally do that by changing the TZ on your container/host.
So how are you deploying this app?
Docker container. But I also want to test, debug locally
Well, consider using
DateTimeOffset.UtcNow
and such. You can't set the timezone for just .NET, it uses your servers timezone
even better, use a timeprovider
and the usual recommendation, if proper time handling is crucial to your app, consider using NodaTime or similarWith TZ, I make sure that it will be in UTC, But I also need to test/debug locally.