UncleCoder.com

UncleCoder.com

Free programming examples and instructions

Get Indian time in C# -Asp.net

Demo and Code for how to get Indian time in C# -Asp.net

by Athil


Posted on 27 Jul 2018 Category: Asp.net Views: 313


Here I am going to show how to get Indian/any other countries Date and time in C# with timezone difference.

DEMO

DOWNLOAD DEMO

//Indian time 
//Time zone +5.30
TextBox1.Text = DateTime.UtcNow.AddHours(5).AddMinutes(30).ToString();

Here I added 5 hours and 30 minutes to UTC time as we know that difference is 5 h and 30 m with Indian time and UTC time. 

Like that we can take all other countries time.

 

Eg: - 

For getting China Time 

     //China time 
     //Time zone +8
     TextBox1.Text = DateTime.UtcNow.AddHours(8).AddMinutes(0).ToString();

 

For Getting UAE Time

        //UAE Time
        //Time zone  +4
        TextBox1.Text = DateTime.UtcNow.AddHours(4).AddMinutes(0).ToString();

For getting Saudi Arabia Time

  //Saudi Arabia (KSA) Time
  //Time zone  +3
  TextBox1.Text = DateTime.UtcNow.AddHours(5).AddMinutes(0).ToString();

For getting Pakistan Time

 //Pakistan ATime
 //Time zone  +5
 TextBox1.Text = DateTime.UtcNow.AddHours(5).AddMinutes(0).ToString();

 



Leave a Comment: