Manoj Maharana

Manoj Maharana

  • NA
  • 362
  • 127.4k

GMT time matching in c# mvc not working

Jan 19 2017 9:05 AM

GMT time matching in c# mvc not working.

Problems having fetch of time difference is not correct.

Here is the code i am tred but not working:

  1. DateTime newDateTime = Convert.ToDateTime(DateNw).Add(TimeSpan.Parse(Time));  
  2.                 ////New Zealand  
  3.                 string nzTimeZoneKey = Country + " Standard Time";  
  4.                 string date = newDateTime.ToUniversalTime().ToString("u");  
  5.                 DateTime localDateTime = DateTime.Parse(date);  
  6.                 DateTime utcDateTime = localDateTime.ToUniversalTime();  
  7.                 TimeZoneInfo nzTimeZone = TimeZoneInfo.FindSystemTimeZoneById(nzTimeZoneKey);  
  8.                 DateTime nzDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcDateTime, nzTimeZone);  
  9.                 //return nzDateTime;  

The above code working for India and afganistan working very well but if i change the country between india and fiji it is not working.

I want GMT time matching for all the country where i can differnciate two country time. Any suggestion???


Answers (2)