Help: I have a server that has a time in GMT-07.00. My local time is GMT + 05.30 hours. I need to get the current date and time from the server and convert this date and time to my local time. I tried a lot of codes, but still have not found a consistent way to do this. Can someone please help me.
string zoneId = "India Standard Time";
TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById(zoneId);
DateTime result = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, tzi);
DateTime cu = result.ToUniversalTime();
DateTime cur = cu.ToLocalTime();
I have tried all of the above methods, but I am not getting the correct answer. Suppose my current local time is March 09, 2014 12:51:00, then my server time will be 12.30 hours different from my local time, that is, subtract 12 hours and 30 minutes from my local time to get the time of my server . I need to get local time from the server. How can I get this? Please suggest me some solutions. Thanks in advance for your answers.
source
share