C# Program to Get the System Time by Zone ID

You are currently viewing C# Program to Get the System Time by Zone ID

C# program to get the system time by Zone Id

using System;
using System.Globalization;
using System.Collections.ObjectModel;

class TimeZoneInfoDemo
    //Entry point of Program
    static public void Main()
        DateTime utcTime = DateTime.UtcNow;
        //Declared TimeZoneInfo objects.
        TimeZoneInfo IndianStandardZone;
        TimeZoneInfo EasternStandardZone;
        TimeZoneInfo CentralStandardZone;

        //Declared date time objects.
        DateTime IndianStandardTime;
        DateTime EasternStandardTime;
        DateTime CentralStandardTime;

        //Here we get Eastern Standard Time
        EasternStandardZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
        EasternStandardTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, EasternStandardZone);
        Console.WriteLine("Eastern Standard Time: "+EasternStandardTime);

        //Here we get India Standard Time
        IndianStandardZone = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
        IndianStandardTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, IndianStandardZone);
        Console.WriteLine("India Standard Time: "+IndianStandardTime);

        //Here we get Central Standard Time
        CentralStandardZone = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
        CentralStandardTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, CentralStandardZone);
        Console.WriteLine("Central Standard Time: "+CentralStandardTime);


Eastern Standard Time: 2/4/2020 11:23:52 AM
India Standard Time: 2/4/2020 9:53:52 PM
Central Standard Time: 2/4/2020 10:23:52 AM
Press any key to continue . . .

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply