Convert UTC to IST using C#

前端 未结 2 1269
青春惊慌失措
青春惊慌失措 2021-01-01 01:45

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



        
相关标签:
2条回答
  • 2021-01-01 01:59

    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
    
    0 讨论(0)
  • 2021-01-01 02:07

    You could 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"));
    
    0 讨论(0)
提交回复
热议问题