Search code examples
c#timezoneutc

Convert UTC to IST using C#


I have tried to convert a Specific UTC time into IST time. But, I got the same date as the output.

// utcdate is 6/15/2014 12:00:00 AM

var istdate = TimeZoneInfo.ConvertTimeFromUtc(utcdate,
              TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));

Output :6/15/2014 12:00:00 AM

Could you please guide me to resolve this issue?


Solution

  • Try This:

    DateTime utcdate = DateTime.ParseExact("6/15/2014 12:00:00 AM", "M/dd/yyyy 
                                           h:mm:ss tt",CultureInfo.InvariantCulture);
    var istdate = TimeZoneInfo.ConvertTimeFromUtc(utcdate,
    TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
    

    I'm getting output :

    6/15/2014 5:30:00 AM