I'm hosting my system on a server that is in the USA.
So when using
DateTime.Now returns the US date and time.
I would like you to return the date and time in Brazil. It's possible?
You need to convert to the desired time zone, like this:
TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("E. South America Standard Time"))
See working on .NET Fiddle . I also put it on GitHub for future reference . Note that it is hosted in another country but configures the server with universal time. It doesn't matter in this case because the conversion is done over local time considering the time zone that is actually being used.
I don't think so but see if there's a more suitable spindle for you.
You can create a method to get the local time:
public DateTime PegaHoraBrasilia() => TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("E. South America Standard Time"));
Give the name that suits you best. And call this method whenever you want the
DateTime.Now in Brasilia time.