Hi, my problem i reckon has a super simple solution im not seeing.
I need to display 3 different timezones updating in realtime. I can easily display my local time using DateTime.Now. However i also need to display UK and Singapores timezone. How would i go about doing that? I’ve been thinking about offsetting my local time, but for the life of me i cannot figure out the syntax.
Here’s my code, i’ve set the timer interval to 500.
private void timer1_Tick_1(object sender, EventArgs e)
{
tidKøbenhavn.Text = DateTime.Now.ToString();
tidLondon.Text = DateTime.UtcNow.ToString();
//tidSingapore.Text = DateTime.UtcNow.ToString();
//tidSingapore.Text = DateTime.UtcNow.Addhours(8).ToString;
}
Check out TimeZoneInfo:
https://docs.microsoft.com/en-us/dotnet/api/system.timezoneinfo.converttime?view=net-5.0
Thank you, it looks like i finally have it working! I never would of figured this out!
This is the code i’ve ended up using:
tidSingapore.Text = TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById(“Singapore Standard Time”)).ToString();