0

Is there a way to force C# application to use different timezone than one, received from Windows?

Preferably through settings (app.config, ...) or some block of code on initialization. Global replacement of usages like .ToLocalTime() or DateTime.Now is highly undesirable as number of such usages in project is 1000+.

I tried to play with TimeZone and TimeZoneInfo private fields, overriding stored TimeZone data but I don't know how to catch system calls inside of private class.

user1782982
  • 75
  • 2
  • 9

1 Answers1

-1

DateTime has a UTCNow which retuns the UTC version of Now from UTC you can calculate any timezone with .AddHours(...)

Alex Anderson
  • 840
  • 5
  • 11