In below code we get date and time of two time zones, first "India Standard Time" and "Central America Standard Time".
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace TimeZoneDemo {
- class Program {
- static void Main(string[] args) {
- DateTime dateTime;
- var timezone = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
- dateTime = TimeZoneInfo.ConvertTime(DateTime.Now, timezone);
- Console.WriteLine("{0}: {1}", "India Standard Time", dateTime);
- timezone = TimeZoneInfo.FindSystemTimeZoneById("Central America Standard Time");
- dateTime = TimeZoneInfo.ConvertTime(DateTime.Now, timezone);
- Console.WriteLine("{0}: {1}", "Central America Standard Time", dateTime);
- Console.ReadLine();
- }
- }
- }
