I had this problem that my web applications were hosted in a server abroad. This meant time zone difference. I needed to save the data with an absolute value and when displaying it, I display it according to client preferences.
To do this I saved the DateTime value in UTC standard (Coordinated Universal Time). More about it here.
As in the following code in C# :
DateTime timeUtc = System.DateTime.UtcNow;
When retrieving data, i converted the DateTime value into the desired TimeZone as follows:
To do this I saved the DateTime value in UTC standard (Coordinated Universal Time). More about it here.
As in the following code in C# :
DateTime timeUtc = System.DateTime.UtcNow;
When retrieving data, i converted the DateTime value into the desired TimeZone as follows:
TimeZoneInfo cstZone = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
DateTime cstTime = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, cstZone);
Thanks,
Nerdy Geeky J!
No comments:
Post a Comment