How do I get DateTime.Now for specific region?
I'm trying to get the current date in a foreign country, I'm looking for an easy way to achieve this.
Note: I don't mind getting the value from an online server, I just don't want to spend too much dev-time for it.
If you know the timezone you want, you can use the TimeZoneInfo class. First get the TimeZoneInfo object for your desired timezone, then convert current time to that timezone:
var timezone = TimeZoneInfo.FindSystemTimeZoneById("Central America Standard Time");
var dateTime = TimeZoneInfo.ConvertTime(DateTime.Now, timezone);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With