Simple Time Zone For All Countries Using C# Code

Here, I have created a Windows Application, where you are able to see few countries current time zone.

In one of my project, it was required to set the time zone of different countries, so it was very difficult to find the country's current timezone in few seconds. Thus, I thought, it's better to develop a program, where every one can easily see the country time zone.

Please look into the steps given below, where I have develped a prgram, using C# code.

I opened Visual Studio, created an Empty Project and name of the project is Country Time Zone.

Simply drag and drop labels from Toolbox under menu in Visual Studio. Afterwards, design your page, as per your requirement.

Afterwards, add Timer control at the end of the page because it will update the time automatically. Once you drop Timers at the end of the page, set the few properties.

Enable: Default: False : Change to True.
Interval : Default:1000: Change to 20.

Once you set the properties, double click on Timer control and it will redirect to Code view. Please check the code given below to show current time zone of the different countries. 

using System;  
using System.Collections.Generic;  
using System.ComponentModel;  
using System.Data;  
using System.Drawing;  
using System.Globalization;  
using System.Linq;  
using System.Text;  
using System.Threading.Tasks;  
using System.Windows.Forms;  
  
namespace getNotepadFile  
{  
    public partial class CountryTime : Form  
    {  
        public CountryTime()  
        {  
            InitializeComponent();  
        }  
  
        private void timer1_Tick(object sender, EventArgs e)  
        {  
  
            var inTimeZone = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");  
            DateTime inTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, inTimeZone);  
            label2.Text = Convert.ToString(inTime);  
        }  
  
        private void timer2_Tick(object sender, EventArgs e)  
        {  
            var euTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time");
            DateTime euTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, euTimeZone);
            label3.Text = Convert.ToString(euTime);
        }  
  
        private void timer4_Tick(object sender, EventArgs e)  
        {  
            var ukTimeZone = TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time");  
            DateTime ukTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, ukTimeZone);  
            label21.Text = Convert.ToString(ukTime);  
        }  
  
        private void timer10_Tick(object sender, EventArgs e)  
        {  
            var euTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time"); 
            DateTime euTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, euTimeZone);
            label13.Text = Convert.ToString(euTime);
        }  
  
        private void timer11_Tick(object sender, EventArgs e)  
        {  
            var siTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Singapore Standard Time");  
            DateTime siTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, siTimeZone);  
            label15.Text = Convert.ToString(siTime);  
        }  
  
        private void timer9_Tick(object sender, EventArgs e)  
        {  
            var MaTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Mountain Standard Time");  
            DateTime MaTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, MaTimeZone);  
            label7.Text = Convert.ToString(MaTime);  
        }  
  
        private void timer3_Tick(object sender, EventArgs e)  
        {  
            var AmTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Central America Standard Time");  
            DateTime AmTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, AmTimeZone);  
            label9.Text = Convert.ToString(AmTime);  
        }  
  
        private void timer13_Tick(object sender, EventArgs e)  
        {  
              
            var SoTimeZone = TimeZoneInfo.FindSystemTimeZoneById("South Africa Standard Time");  
            DateTime SoTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, SoTimeZone);  
            label19.Text = Convert.ToString(SoTime);  
        }  
  
        private void timer12_Tick(object sender, EventArgs e)  
        {  
              
            var ArTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Arabian Standard Time");  
            DateTime ArTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, ArTimeZone);  
            label17.Text = Convert.ToString(ArTime);  
        }  
  
        private void timer8_Tick(object sender, EventArgs e)  
        {  
              
            var ChTimeZone = TimeZoneInfo.FindSystemTimeZoneById("China Standard Time");  
            DateTime ChTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, ChTimeZone);  
            label23.Text = Convert.ToString(ChTime);  
        }  
  
        private void timer6_Tick(object sender, EventArgs e)  
        {  
              
            var BnTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Bangladesh Standard Time");  
            DateTime BaTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, BnTimeZone);  
            label25.Text = Convert.ToString(BaTime);  
        }  
  
        private void timer7_Tick(object sender, EventArgs e)  
        {  
            var CaTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Canada Central Standard Time");  
            DateTime CaTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, CaTimeZone);  
            label5.Text = Convert.ToString(CaTime);  
        }  
  
        private void timer5_Tick(object sender, EventArgs e)  
        {  
            var BrTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Central Brazilian Standard Time");  
            DateTime BrTime = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, BrTimeZone);  
            label11.Text = Convert.ToString(BrTime);
        }  
    }  
}

Once you completed the code, Debug the prgram on top of Visual Studio. Please look into the images given below for the output.

Please let me know, if anyone is facing any problem.

HCL Tech
HCL Tech