Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
SQL Server

Check Time According To Different Time Zone Using Visual Basic.Net

Author: DevASP
Download Source Code : 560_Universal Time

This article is about how you can create an application in which the user can change the time zone according to his/her choice. In this application we will provide radio buttons to select the time zone.

  • Steps you will do. 
  • Start visual studio and create a new window application. 
  • Drop a label control on the form and set its following properties.


Name = “Label1”

BackColor = “Control”

Font = “Times New Roman, 20pt”

FontColor = “255, 224, 192”

Location = “0, 0”

TextAlign = “MiddleCenter”

Text = “”



Now on first label control drop another label but at the top of first label and set its following properties.


Name  = “Label2”

Font = “Times New Roman, 15pt”

Location = “184, 0”

TextAlign = “MiddleCenter”

Text = “G.M.T”



Now drop seven radio buttons on the form and make them align in a line, set their text properties respectively as below.



Text =” Pakistani Time”



Text = “G.M.T”



Text = “New York



Text = “Canada



Text = “Australia



Text = “New Zealand



Text = “Switzerland



Now drop a timer control on the form and set its following properties.


Name = “Timer1”

Enabled = “True”

Interval = “1000”

Modifiers = “Friend“


Open the code window and write the following code in the load event of the form.


Label1.Font = New Font(Label1.Font.SizeInPoints, 36)


Label1.BackColor = System.Drawing.Color.Black


Label1.ForeColor = System.Drawing.Color.Cyan


Label2.BackColor = System.Drawing.Color.Black


Label2.ForeColor = System.Drawing.Color.Lime


Now write the following code in the ‘tick event’ of the timer control.


Label1.Text = DateTime.Now.AddHours(-5.5)


If RadioButton1.Checked Then

Label1.Text = DateTime.Now

Label2.Text = "PAKISTAN TIME"

End If


If RadioButton2.Checked Then

Label1.Text = DateTime.Now.AddHours(-5.5)

Label2.Text = "G.M.T"

End If


If RadioButton3.Checked Then

Label1.Text = DateTime.Now.AddHours(-9.5)

Label2.Text = "NEW YORK TIME"

End If


If RadioButton4.Checked Then

Label1.Text = DateTime.Now.AddHours(-9.5)

Label2.Text = "VANCOUVER TIME"

End If


If RadioButton5.Checked Then

Label1.Text = DateTime.Now.AddHours(4.5)


End If


If RadioButton6.Checked Then

Label1.Text = DateTime.Now.AddHours(6.5)

Label2.Text = "NEW ZEALAND TIME"

End If


If RadioButton7.Checked Then

Label1.Text = DateTime.Now.AddHours(-3.5)


End If


Run your application and click on checkboxes to see the time of different countries.

Article Comments
Too simplistic. Does not even take care of the DST changes.

Posted on 4/4/2007 7:30:35 AM by Pankaj

Add Article Comment:
Name :
Email Address :
Comments :
<< Creating Control Panel in your Applications

Disclaimer - Privacy
© 2002-2017