Convert UTC to IST using C #

I tried to convert a specific UTC time to IST time. But I got the same date as the output.

// utcdate - 6/6/2014 12:00:00 AM

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

Day off: 06/15/2014, 12:00:00

Could you help me solve this problem?

+6
source share
2 answers

Try the following:

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 get the output:

6/15/2014 5:30:00 AM
+12
source

You can also try:

        DateTime utc = TimeZoneInfo.ConvertTimeToUtc(new DateTime(2014, 6, 16, 2, 0, 0));
        DateTime temp = new DateTime(utc.Ticks, DateTimeKind.Utc);
        DateTime ist = TimeZoneInfo.ConvertTimeFromUtc(temp, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
+2
source

Source: https://habr.com/ru/post/1544707/


All Articles